withPrecompressedMediaTypeSupport
Signature
def withPrecompressedMediaTypeSupport: Directive0
Description
Inspects the response entity and adds a Content-Encoding: gzip
response header if the entity’s media-type is precompressed with gzip and no Content-Encoding
header is present yet.
Example
val svgz = compress("<svg/>", Gzip)
val route =
withPrecompressedMediaTypeSupport {
complete(HttpResponse(entity = HttpEntity(`image/svgz`, svgz)))
}
// tests:
Get("/") ~> route ~> check {
header[`Content-Encoding`] shouldEqual Some(`Content-Encoding`(gzip))
mediaType shouldEqual `image/svg+xml`
}