jooby/src/main/java/org/jooby/Deferred.java
@Nonnull
  public static Deferred deferred(final String executor, final Route.OneArgHandler handler) {
    return new Deferred(executor, (req, deferred) -> {
      try {
        deferred.resolve(handler.handle(req));
      } catch (Throwable x) {
        deferred.reject(x);
      }
    });
  }
@Nonnull
  public static Deferred deferred(final String executor, final Route.OneArgHandler handler) {
    return new Deferred(executor, (req, deferred) -> {
      try {
        deferred.resolve(handler.handle(req));
      } catch (Throwable x) {
        deferred.reject(x);
      }
    });
  }
@ Nonnull public static Deferred deferred ( final String executor , final Route . OneArgHandler handler ) { return new Deferred ( executor , ( req , deferred ) -> { try { deferred . resolve ( handler . handle ( req ) ) ; } catch ( Throwable x ) { deferred . reject ( x ) ; } } ) ; }
Functional version of {@link Deferred#Deferred(Initializer)}. To use ideally with one
or more {@link Executor}:

<pre>{@code
{
executor("cached", Executors.newCachedExecutor());

get("/fork", deferred("cached", req -> {
return req.param("value").value();
}));
}
}</pre>

This handler automatically {@link Deferred#resolve(Object)} or
{@link Deferred#reject(Throwable)} a route handler response.

@param executor Executor to run the deferred.
@param handler Application block.
@return A new deferred handler.
Functional version of { @link Deferred#Deferred ( Initializer ) } . To use ideally with one or more { @link Executor } :