mapRequestContext
Transforms the RequestContext before it is passed to the inner route.
Signature
def mapRequestContext(f: RequestContext ⇒ RequestContext): Directive0
Description
The mapRequestContext directive is used as a building block for Custom Directives to transform the request context before it is passed to the inner route. To change only the request value itself the mapRequest directive can be used instead.
See Directives transforming the request for an overview of similar directives.
Example
val probe = TestProbe()
val replaceResponder = mapRequestContext(_.copy(responder = probe.ref))
val route =
replaceResponder {
complete("abc")
}
Get("/abc/def/ghi") ~> route ~> check {
handled === false
}
probe.expectMsgType[HttpMessagePartWrapper].messagePart === HttpResponse(entity = HttpEntity("abc"))