| Interface | Description |
|---|---|
| AuthHandler |
Basic interface for implementing an AuthHandler.
|
| ChunkResponder |
A responder for sending chunk-encoded response
|
| HandlerContext |
Place holder for information about the environment.
|
| HandlerHook |
Interface that needs to be implemented to intercept handler method calls.
|
| HttpHandler |
Interface that needs to be implemented for handling HTTP methods.
|
| HttpResponder |
HttpResponder is used to send response back to clients.
|
| URLRewriter |
Re-writes URL of an incoming request before any handlers or their hooks are called.
|
| Class | Description |
|---|---|
| AbstractHandlerHook |
A base implementation of
HandlerHook that provides no-op for both
HandlerHook.preCall(HttpRequest, HttpResponder, HandlerInfo)
and HandlerHook.postCall(HttpRequest, HttpResponseStatus, HandlerInfo) methods. |
| AbstractHttpHandler |
A base implementation of
HttpHandler that provides a method for sending a request to other
handlers that exist in the same server. |
| AbstractHttpResponder |
Base implementation of
HttpResponder to simplify child implementations. |
| BodyConsumer |
HttpHandler would extend this abstract class and implement methods to stream the body directly.
|
| BodyProducer |
Class for producing response body in streaming fashion.
|
| ChannelPipelineModifier |
This class allows user modify a
ChannelPipeline when it gets initialized, which happens on every
new channel |
| ExceptionHandler |
Handles exceptions and provides a response via the
HttpResponder. |
| NettyHttpService |
Webservice implemented using the netty framework.
|
| NettyHttpService.Builder |
Builder to help create the NettyHttpService.
|
| SSLConfig |
A class that encapsulates SSLContext configuration.
|
| SSLConfig.Builder |
Builder to help create the SSLConfig.
|
| SSLHandlerFactory |
A class that encapsulates SSL Certificate Information.
|
| Annotation Type | Description |
|---|---|
| RequiredRoles |
Indicates that the annotated method should only be called if the requesting
HttpRequest was deemed authorized by the registered's
AuthHandler.hasRoles(io.netty.handler.codec.http.HttpRequest, String[]) method. |
| Secured |
Indicates that the annotated method should only be called if the requesting
HttpRequest was deemed authenticated by the
registered's AuthHandler.isAuthenticated(io.netty.handler.codec.http.HttpRequest) method. |
NettyHttpService sets up the necessary pipeline and manages starting, stopping,
state-management of the web service.
In-order to handle http requests, HttpHandler must be implemented. The methods
in the classes implemented from HttpHandler must be annotated with Jersey annotations to
specify http uri paths and http methods.
Note: Only supports the following annotations:
Path,
PathParam,
GET,
PUT,
POST,
DELETE,
RequiredRoles,
Secured.
Note: Doesn't support getting Annotations from base class if the HttpHandler implements also extends
a class with annotation.
Sample usage Handlers and Netty service setup:
//Setup Handlers
@Path("/common/v1/")
public class ApiHandler implements HttpHandler {
@Path("widgets")
@GET
public void widgetHandler(HttpRequest request, HttpResponder responder) {
responder.sendJson(HttpResponseStatus.OK, "{\"key\": \"value\"}");
}
@Override
public void init(HandlerContext context) {
//Perform bootstrap operations before any of the handlers in this class gets called.
}
@Override
public void destroy(HandlerContext context) {
//Perform teardown operations the server shuts down.
}
}
//Set up and start the http service
NettyHttpService service = NettyHttpService.builder()
.addHttpHandlers(ImmutableList.of(new Handler())
.setPort(8989)
.build();
service.start();
// ....
//Stop the web-service
service.shutdown();
Copyright 2020 Cask, Inc. Licensed under the Apache License, Version 2.0