mapRouteResponse

Changes the message the inner route sends to the responder.

Signature

def mapRouteResponse(f: Any  Any): Directive0 

Description

The mapRouteResponse directive is used as a building block for Custom Directives to transform what the inner route sends to the responder (see The Responder Chain).

See Directives hooking into the responder chain for similar directives.

Example

val rejectAll = // not particularly useful directive
  mapRouteResponse {
    case _ => Rejected(List(AuthorizationFailedRejection))
  }
val route =
  rejectAll {
    complete("abc")
  }

Get("/") ~> route ~> check {
  rejections.nonEmpty === true
}