[−][src]Function rouille::content_encoding::apply
pub fn apply(request: &Request, response: Response) -> Response
Applies content encoding to the response.
Analyzes the Accept-Encoding
header of the request. If one of the encodings is recognized and
supported by rouille, it adds a Content-Encoding
header to the Response
and encodes its
body.
If the response already has a Content-Encoding
header, this function is a no-op.
If the response has a Content-Type
header that isn't textual content, this function is a
no-op.
The gzip encoding is supported only if you enable the gzip
feature of rouille (which is
enabled by default).
Example
use rouille::content_encoding; use rouille::Request; use rouille::Response; fn handle(request: &Request) -> Response { content_encoding::apply(request, Response::text("hello world")) }