- All Known Subinterfaces:
RestEndpoint
- All Known Implementing Classes:
RestEndpointBuilder
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
The
RestRequestConsumer
can be coded using the lambda
syntax and processes a request for a given locator and for a given
HttpMethod
. A RestRequestConsumer
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)
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
onRequest
(RestRequestEvent aRequest, org.refcodes.web.HttpServerResponse aResponse) The invoker provides a request context being aRestRequestEvent
) describing the request and a response being aHttpServerResponse
to be processed upon by yourlambda
's code.
-
Method Details
-
onRequest
void onRequest(RestRequestEvent aRequest, org.refcodes.web.HttpServerResponse aResponse) throws org.refcodes.web.HttpStatusException The invoker provides a request context being aRestRequestEvent
) describing the request and a response being aHttpServerResponse
to be processed upon by yourlambda
's code. The method works synchronously and waits (blocks the caller's thread) till it finishes execution.- Parameters:
aRequest
- The request of typeRestRequestEvent
describing the request context. UseHttpServerRequest.getRequest(Class)
to retrieve the caller's request body orAbstractHttpRequest.getHeaderFields()
to retrieve the request's cookies and other Header-Fields.aResponse
- The response of typeHttpServerResponse
do be processed upon by the method's implementation. UseHttpServerResponse.setResponse(Object)
to provide a response for the client. UseAbstractHttpResponse.getHeaderFields()
to set cookies or modify Header-Fields. Throw one of theHttpStatusException
sub-types to signal an according erroneous HTTP state.- Throws:
org.refcodes.web.HttpStatusException
- to be thrown in case something went wrong.
-