respondWithHeaders
Signature
Description
Adds the given HTTP headers to all responses coming back from its inner route.
This directive transforms HttpResponse
and ChunkedResponseStart
messages coming back from its inner route by
adding the given HttpHeader
instances to the headers list.
See also respondWithHeader if you'd like to add just a single header.
Example
val route =
path("foo") {
respondWithHeaders(RawHeader("Funky-Muppet", "gonzo"), Origin(HttpOrigin("http://akka.io"))) {
complete("beep")
}
}
// tests:
Get("/foo") ~> route ~> check {
header("Funky-Muppet") shouldEqual Some(RawHeader("Funky-Muppet", "gonzo"))
header[Origin] shouldEqual Some(Origin(HttpOrigin("http://akka.io")))
responseAs[String] shouldEqual "beep"
}
Contents