RestEndpoint, RestEndpointBuilderRestEndpointBuilderImpl@FunctionalInterface public interface RestRequestObserver
RestRequestObserver can be coded using the lambda
syntax and processes a request for a given locator and for a given
HttpMethod. A RestRequestObserver is invoked with a request
of type RestRequestEvent and a response being of type
HttpServerResponse. The RestRequestEvent describes the
context of the request whereas the HttpServerResponse is used by the
lambda expression to prepare the response e.g. via
HttpServerResponse.setResponse(Object).| Modifier and Type | Method | Description |
|---|---|---|
void |
onRequest(RestRequestEvent aRequest,
org.refcodes.net.HttpServerResponse aResponse) |
The invoker provides a request context being a
RestRequestEvent)
describing the request and a response being a HttpServerResponse
to be processed upon by your lambda's code. |
void onRequest(RestRequestEvent aRequest, org.refcodes.net.HttpServerResponse aResponse) throws org.refcodes.net.HttpStatusException
RestRequestEvent)
describing the request and a response being a HttpServerResponse
to be processed upon by your lambda's code. The method works
synchronously and waits (blocks the caller's thread) till it finishes
execution.aRequest - The request of type RestRequestEvent describing
the request context. Use
HttpServerRequest.getRequest(Class) to retrieve the
caller's request body or
HeaderFieldsAccessor.getHeaderFields() to retrieve the
request's cookies and other Header-Fields.aResponse - The response of type HttpServerResponse do be
processed upon by the method's implementation. Use
HttpServerResponse.setResponse(Object) to provide a
response for the client. Use
HeaderFieldsAccessor.getHeaderFields() to set cookies or
modify Header-Fields. Throw one of the HttpStatusException
sub-types to signal an according erroneous HTTP state.org.refcodes.net.HttpStatusException - to be thrown in case something went wrong.Copyright © 2018. All rights reserved.