public CompletionStage < Result > call ( Request req ) { // TODO: Make this method abstract after removing call(Context) return Context . safeCurrent ( ) . map ( threadLocalCtx -> { // A previous action did explicitly set a context onto the thread local (via // Http.Context.current.set(...)) // Let's use that context so the user doesn't loose data he/she set onto that ctx // (args,...) Context newCtx = threadLocalCtx . withRequest ( req . removeAttr ( CTX_ARGS ) ) ; Context . setCurrent ( newCtx ) ; return call ( newCtx ) ; } ) . orElseGet ( ( ) -> { // A previous action did not set a context explicitly, we simply create a new one to // pass on the request Context ctx = new Context ( req . removeAttr ( CTX_ARGS ) , contextComponents ) ; ctx . args = req . attrs ( ) . getOptional ( CTX_ARGS ) . orElse ( new HashMap <> ( ) ) ; return call ( ctx ) ; } ) ; }
Executes this action with the given HTTP request and returns the result .