Allows running an inner route using an alternative ExecutionContextExecutor in place of the default one.
The execution context can be extracted in an inner route using extractExecutionContext directly, or used by directives which internally extract the materializer without surfacing this fact in the API.
sourceimport static akka.http.javadsl.server.Directives.withExecutionContext;finalExecutionContextExecutor special =ExecutionContexts.fromExecutor(Executors.newFixedThreadPool(1));finalRoute sample = path("sample",()->
extractExecutionContext(executor ->
onSuccess(()->CompletableFuture.supplyAsync(()->"Run on "+ executor.hashCode()+"!", executor
),Directives::complete
)));finalRoute route =Directives.concat(
pathPrefix("special",()->// `special` execution context will be used
withExecutionContext(special,()-> sample)),
sample // default execution context will be used);// tests:
testRoute(route).run(HttpRequest.GET("/sample")).assertEntity("Run on "+ system().dispatcher().hashCode()+"!");
testRoute(route).run(HttpRequest.GET("/special/sample")).assertEntity("Run on "+ special.hashCode()+"!");