- All Superinterfaces:
ServerLifecycle
- All Known Implementing Classes:
CorsSupport
,SecureHandler
,SecurityHandler
Handle a server request and server response.
Handlers are used to construct routing.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Handler
create
(Class<T> type, BiConsumer<T, ServerResponse> handler) Create a handler that consumes type request entity andServerResponse
.static <T> Handler
Create a handler that consumes typed request entity and sendsStatus.OK_200
.static <T> Handler
Create a handler that consumes typed request entity and produces an entity object.static Handler
Create a handler that only runs code and returnsStatus.OK_200
.static Handler
create
(Consumer<ServerRequest> handler) Create a handler that consumes aServerRequest
and returnsStatus.OK_200
.static Handler
create
(Function<ServerRequest, ?> handler) Create a handler that consumes aServerRequest
and returns an entity object.static Handler
Create a handler that produces an entity.void
handle
(ServerRequest req, ServerResponse res) Handle request.Methods inherited from interface io.helidon.webserver.ServerLifecycle
afterStop, beforeStart
-
Method Details
-
create
Create a handler that only runs code and returnsStatus.OK_200
.- Parameters:
handler
- runnable to run- Returns:
- handler
-
create
Create a handler that consumes aServerRequest
and returnsStatus.OK_200
.- Parameters:
handler
- consumer of request- Returns:
- handler
-
create
Create a handler that consumes aServerRequest
and returns an entity object.- Parameters:
handler
- function that gets a request and produces an entity- Returns:
- handler
-
create
Create a handler that produces an entity.- Parameters:
handler
- supplier of entity object- Returns:
- handler
-
create
Create a handler that consumes typed request entity and produces an entity object.- Type Parameters:
T
- type of the request entity- Parameters:
type
- type of the request entityhandler
- function that gets request entity and produces response entity- Returns:
- handler
-
create
Create a handler that consumes typed request entity and sendsStatus.OK_200
.- Type Parameters:
T
- type of request entity- Parameters:
type
- type of request entityhandler
- consumer of request entity- Returns:
- handler
-
create
Create a handler that consumes type request entity andServerResponse
.- Type Parameters:
T
- type of request entity- Parameters:
type
- type of request entityhandler
- consumer of typed request entity and server response- Returns:
- handler
-
handle
Handle request. This method must not return before the response is completed. If the method does asynchronous operations, it must wait for them to complete before returning.- Parameters:
req
- requestres
- response- Throws:
Exception
- may throw checked exceptions that are handled by the server, either by error handler, or by returning an internal server error (default handling)
-