Package org.refcodes.rest
Interface RestRequestObserver
-
- All Known Subinterfaces:
RestEndpoint
,RestEndpointBuilder
- All Known Implementing Classes:
RestEndpointBuilderImpl
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface RestRequestObserver
TheRestRequestObserver
can be coded using thelambda
syntax and processes a request for a given locator and for a givenHttpMethod
. ARestRequestObserver
is invoked with a request of typeRestRequestEvent
and a response being of typeHttpServerResponse
. TheRestRequestEvent
describes the context of the request whereas theHttpServerResponse
is used by thelambda
expression to prepare the response e.g. viaHttpServerResponse.setResponse(Object)
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
onRequest(RestRequestEvent aRequest, org.refcodes.net.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 Detail
-
onRequest
void onRequest(RestRequestEvent aRequest, org.refcodes.net.HttpServerResponse aResponse) throws org.refcodes.net.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 orHeaderFieldsAccessor.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. UseHeaderFieldsAccessor.getHeaderFields()
to set cookies or modify Header-Fields. Throw one of theHttpStatusException
sub-types to signal an according erroneous HTTP state.- Throws:
org.refcodes.net.HttpStatusException
- to be thrown in case something went wrong.
-
-