Package io.github.grumpystuff.grumpyrest
Interface ComplexHandler
public interface ComplexHandler
Interface for a handler in case a
SimpleHandler is not flexible enough. A complex Handler takes a
RequestCycle. It can, for example, access the ResponseTransmitter directly and stream a large
binary response without loading it all into memory first.
Note that implementing ComplexHandler is not more complex than how a SimpleHandler works, but rather is
needed for more complex cases. The main downside with a complex handler is that a request cycle is much harder to
mock in tests than just a Request. You should therefore implement SimpleHandler whenever possible
to reduce scaffolding for your tests.
-
Method Summary
-
Method Details
-
handle
Handles a request. The general interface is similar toSimpleHandler, except that this method gets the wholeRequestCycleinsteaf of just theRequest. A complex handler can obtain the request by callingRequestCycle.getHighlevelRequest()- Parameters:
requestCycle- the request cycle object which contains all objects related to handling a single request- Returns:
- the response value, just like for
SimpleHandler - Throws:
Exception- on internal errors or faulty requests, just like forSimpleHandler
-