mapResponse

Signature

def mapResponse(f: HttpResponse โ‡’ HttpResponse): Directive0

Description

The mapResponse directive is used as a building block for Custom Directives to transform a response that was generated by the inner route. This directive transforms complete responses.

See also mapResponseHeaders or mapResponseEntity for more specialized variants and Response Transforming Directives for similar directives.

Example: Override status

@@snip BasicDirectivesExamplesSpec.scala { #0mapResponse }

Example: Default to empty JSON response on errors

@@snip BasicDirectivesExamplesSpec.scala { #1mapResponse-advanced }