public abstract class HttpRestHandler
extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.HttpObject>
Modifier and Type | Class and Description |
---|---|
protected static class |
HttpRestHandler.HttpCleanChannelFutureListener |
static class |
HttpRestHandler.METHOD |
Modifier and Type | Field and Description |
---|---|
protected RestArgument |
arguments
Arguments received
|
protected io.netty.buffer.ByteBuf |
cumulativeBody
Cumulative chunks
|
protected DbSession |
dbSession |
protected io.netty.handler.codec.http.multipart.HttpPostRequestDecoder |
decoder |
static RestConfiguration |
defaultConfiguration |
static io.netty.handler.codec.http.multipart.HttpDataFactory |
factory |
static io.netty.channel.group.ChannelGroup |
group |
protected RestMethodHandler |
handler |
protected Object |
jsonObject
JSON decoded object
|
protected io.netty.handler.codec.http.HttpRequest |
request |
protected RestArgument |
response
The only structure that might be needed is: ARGS_COOKIE (subset)
|
RestConfiguration |
restConfiguration |
HashMap<String,RestMethodHandler> |
restHashMap |
protected RootOptionsRestMethodHandler |
rootHandler |
protected io.netty.handler.codec.http.HttpResponseStatus |
status |
static String |
TempPath |
Modifier | Constructor and Description |
---|---|
protected |
HttpRestHandler(RestConfiguration config) |
Modifier and Type | Method and Description |
---|---|
protected void |
bodyChunk(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpContent chunk)
Method that get a chunk of data
|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext ctx,
io.netty.handler.codec.http.HttpObject msg) |
protected abstract void |
checkConnection(io.netty.channel.ChannelHandlerContext ctx)
To be used for instance to check correctness of connection
Note that ARG_METHOD is only set from current request. |
protected void |
clean()
Clean method
Override if needed
|
protected void |
createDecoder()
Create the decoder
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext ctx,
Throwable cause) |
protected void |
finalizeSend(io.netty.channel.ChannelHandlerContext ctx) |
protected void |
forceClosing(io.netty.channel.ChannelHandlerContext ctx)
To allow quick answer even if in very bad shape
|
protected Object |
getBodyJsonArgs(io.netty.buffer.ByteBuf data)
Get Body args as JSON body
|
DbSession |
getDbSession() |
protected RestMethodHandler |
getHandler()
Could be overwritten if necessary
|
io.netty.handler.codec.http.HttpRequest |
getRequest() |
io.netty.handler.codec.http.FullHttpResponse |
getResponse(io.netty.buffer.ByteBuf content) |
io.netty.handler.codec.http.HttpResponseStatus |
getStatus() |
protected void |
initialize()
Called at the beginning of every new request
Override if needed
|
static void |
initialize(String tempPath)
Initialize the Disk support
|
boolean |
isWillClose() |
protected void |
readAllHttpData()
Read all InterfaceHttpData from finished transfer
|
protected void |
readHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData data)
Read one Data
|
protected void |
readHttpDataChunkByChunk()
Read request by chunk and getting values from chunk to chunk
|
protected void |
setCookies(io.netty.handler.codec.http.FullHttpResponse httpResponse)
Method to set Cookies in httpResponse from response ObjectNode
|
void |
setStatus(io.netty.handler.codec.http.HttpResponseStatus status) |
void |
setWillClose(boolean willClose) |
acceptInboundMessage, channelRead
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
public static final io.netty.handler.codec.http.multipart.HttpDataFactory factory
public static String TempPath
public static io.netty.channel.group.ChannelGroup group
public static final RestConfiguration defaultConfiguration
public HashMap<String,RestMethodHandler> restHashMap
public final RestConfiguration restConfiguration
protected final RootOptionsRestMethodHandler rootHandler
protected io.netty.handler.codec.http.multipart.HttpPostRequestDecoder decoder
protected io.netty.handler.codec.http.HttpResponseStatus status
protected io.netty.handler.codec.http.HttpRequest request
protected RestMethodHandler handler
protected DbSession dbSession
protected RestArgument arguments
protected RestArgument response
protected Object jsonObject
protected io.netty.buffer.ByteBuf cumulativeBody
protected HttpRestHandler(RestConfiguration config)
public static void initialize(String tempPath)
tempPath
- system temp directoryIOException
CryptoException
public final void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelActive
in interface io.netty.channel.ChannelInboundHandler
channelActive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
protected final void clean()
Override if needed
protected final void initialize()
Override if needed
public final DbSession getDbSession()
protected abstract void checkConnection(io.netty.channel.ChannelHandlerContext ctx) throws HttpInvalidAuthenticationException
ctx
- HttpInvalidAuthenticationException
protected final void setCookies(io.netty.handler.codec.http.FullHttpResponse httpResponse)
httpResponse
- protected final RestMethodHandler getHandler() throws HttpMethodNotAllowedRequestException, HttpForbiddenRequestException
HttpIncorrectRequestException
HttpMethodNotAllowedRequestException
HttpForbiddenRequestException
protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpObject msg)
channelRead0
in class io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.HttpObject>
protected final void createDecoder() throws HttpIncorrectRequestException
HttpIncorrectRequestException
protected final void readAllHttpData() throws HttpIncorrectRequestException
HttpIncorrectRequestException
protected final void readHttpData(io.netty.handler.codec.http.multipart.InterfaceHttpData data) throws HttpIncorrectRequestException
data
- HttpIncorrectRequestException
protected final void forceClosing(io.netty.channel.ChannelHandlerContext ctx)
ctx
- public final io.netty.handler.codec.http.FullHttpResponse getResponse(io.netty.buffer.ByteBuf content)
content
- protected final void bodyChunk(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.HttpContent chunk) throws HttpIncorrectRequestException, HttpInvalidAuthenticationException, HttpNotFoundRequestException
ctx
- chunk
- HttpIncorrectRequestException
HttpInvalidAuthenticationException
HttpNotFoundRequestException
protected final void finalizeSend(io.netty.channel.ChannelHandlerContext ctx)
protected final Object getBodyJsonArgs(io.netty.buffer.ByteBuf data) throws HttpIncorrectRequestException
data
- HttpIncorrectRequestException
protected final void readHttpDataChunkByChunk() throws HttpIncorrectRequestException
HttpIncorrectRequestException
public final void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
Exception
public final io.netty.handler.codec.http.HttpResponseStatus getStatus()
public final void setStatus(io.netty.handler.codec.http.HttpResponseStatus status)
status
- the status to setpublic final io.netty.handler.codec.http.HttpRequest getRequest()
public final boolean isWillClose()
public final void setWillClose(boolean willClose)
willClose
- the willClose to setCopyright © 2009–2022 Waarp. All rights reserved.