responseEncodingAccepted

responseEncodingAccepted

Signature

Description

Passes the request to the inner route if the request accepts the argument encoding. Otherwise, rejects the request with an UnacceptedResponseEncodingRejection(encoding).

Example

val route = responseEncodingAccepted(gzip) { complete("content") }

Get("/") ~> route ~> check {
  responseAs[String] shouldEqual "content"
}
Get("/") ~> `Accept-Encoding`(deflate) ~> route ~> check {
  rejection shouldEqual UnacceptedResponseEncodingRejection(gzip)
}

Contents