public interface Take
Take is a momentary snapshot of in-server reality, visible to the
end user via printable Response
.
For example, this is a simple web server
that returns "hello, world!" plain text web page:
new FtBasic( new Take() { @Override public Response act(final Request req) { return new RsText("hello, world!"); } }, 8080 ).start(Exit.NEVER); }
There are a few classes that implement this interface and you
can create your own. But the best way is to start with
TkFork
, for example:
new FtBasic( new TkFork(new FkRegex("/", "hello, world!")), 8080 ).start(Exit.NEVER); }
This code will start an HTTP server on port 8080 and will forward
all HTTP requests to the instance of class
TkFork
.
That object will try to find the best suitable "fork" amongst all
encapsulated objects. There is only one in the example above —
an instance of FkRegex
.
All implementations of this interface must be immutable and thread-safe.
Response act(Request req) throws IOException
req
- Request to processIOException
- If failsCopyright © 2015 Take. All rights reserved.