extractActorSystem
Description
Extracts the ActorSystem
ActorSystem
from the RequestContext
RequestContext
, which can be useful when the external API in your route needs one.
Example
- Scala
-
source
val route = extractActorSystem { actorSystem => complete(s"Actor System extracted, hash=${actorSystem.hashCode()}") } // tests: Get("/") ~> route ~> check { responseAs[String] shouldEqual s"Actor System extracted, hash=${system.hashCode()}" }
- Java
-
source
import static org.apache.pekko.http.javadsl.server.Directives.extractActorSystem; final Route route = extractActorSystem( actorSystem -> complete("Actor System extracted, hash=" + actorSystem.hashCode())); // tests: testRoute(route) .run(HttpRequest.GET("/")) .assertEntity("Actor System extracted, hash=" + system().hashCode());
1.1.0+17-3b5f9b27*