mapHttpResponse
Changes the response that was generated by the inner route.
Signature
def mapHttpResponse(f: HttpResponse ⇒ HttpResponse): Directive0
Description
The mapHttpResponse
directive is used as a building block for Custom Directives to transform a response that
was generated by the inner route. This directive transforms only complete responses. Use mapHttpResponsePart,
instead, to transform parts of chunked responses as well.
See Directives transforming the response for similar directives.
Example
def overwriteResultStatus(response: HttpResponse): HttpResponse =
response.copy(status = StatusCodes.BadGateway)
val route = mapHttpResponse(overwriteResultStatus)(complete("abc"))
Get("/abcdef?ghi=12") ~> route ~> check {
status === StatusCodes.BadGateway
}