responseEncodingAccepted

Description

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

Example

final Route route = responseEncodingAccepted(HttpEncodings.GZIP, () ->
  complete("content")
);

// tests:
testRoute(route).run(HttpRequest.GET("/"))
  .assertEntity("content");
runRouteUnSealed(route,
                 HttpRequest.GET("/")
                   .addHeader(AcceptEncoding.create(HttpEncodings.DEFLATE)))
  .assertRejections(Rejections.unacceptedResponseEncoding(HttpEncodings.GZIP));
The source code for this page can be found here.