Package org.takes.facets.fork
Class FkEncoding
- java.lang.Object
-
- org.takes.facets.fork.FkEncoding
-
- All Implemented Interfaces:
Fork
public final class FkEncoding extends Object implements Fork
Fork by encoding accepted by "Accept-Encoding" HTTP header.Use this fork in order to deliver responses with different encoding, depending on user preferences. For example, you want to deliver GZIP-compressed response when "Accept-Encoding" request header contains "gzip". Here is how:
new TkFork( new FkEncoding("gzip", new RsGzip(response)), new FkEncoding("", response) )
Empty string as an encoding means that the fork should match in any case.
The class is immutable and thread-safe.
- Since:
- 0.10
- See Also:
RsFork
-
-
Constructor Summary
Constructors Constructor Description FkEncoding(String enc, Response response)
Ctor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Opt<Response>
route(Request req)
Process this request or ignore it.
-
-
-
Method Detail
-
route
public Opt<Response> route(Request req) throws IOException
Description copied from interface:Fork
Process this request or ignore it.- Specified by:
route
in interfaceFork
- Parameters:
req
- Request- Returns:
- Non-empty list of responses if it was processed
- Throws:
IOException
-
-