Interface HttpHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Functional interface for handling HTTP requests.
This is the main abstraction for implementing HTTP endpoints in the SDK. It follows a simple request-in/response-out pattern, completely decoupled from any specific HTTP server implementation (Jetty, Netty, etc.).
Example usage:
KokosHandler handler = request -> {
String name = request.queryParam("name");
return HttpResponse.ok("{\"hello\":\"" + name + "\"}");
};
-
Method Summary
Modifier and TypeMethodDescriptionvoidhandle(HttpRequest request, HttpResponse response) Processes an HTTP request and returns an HTTP response.
-
Method Details
-
handle
Processes an HTTP request and returns an HTTP response.- Parameters:
request- the incoming HTTP request (immutable)response- HTTP response to be sent back to the client (immutable)- Throws:
InterruptedException
-