mapRouteResultWithPF

mapRouteResultWithPF

§Signature

§Description

Asynchronous variant of mapRouteResultPF.

Changes the message the inner route sends to the responder.

The mapRouteResult directive is used as a building block for Custom Directives to transform the RouteResult coming back from the inner route.

See Transforming the RouteResult for similar directives.

§Example

  1. case object MyCustomRejection extends Rejection
  2. val rejectRejections = // not particularly useful directive
  3. mapRouteResultWithPF {
  4. case Rejected(_) => Future(Rejected(List(AuthorizationFailedRejection)))
  5. }
  6. val route =
  7. rejectRejections {
  8. reject(MyCustomRejection)
  9. }
  10.  
  11. // tests:
  12. Get("/") ~> route ~> check {
  13. rejection shouldEqual AuthorizationFailedRejection
  14. }