java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
stincmale.server.netty4.tcp.DispatchMonoHandler<RequestWithMetadata<? extends FullHttpRequest>,FullHttpResponse>
stincmale.server.netty4.tcp.http.HttpDispatchMonoHandler
- All Implemented Interfaces:
ChannelHandler
,ChannelInboundHandler
@ThreadSafe @Sharable public class HttpDispatchMonoHandler extends DispatchMonoHandler<RequestWithMetadata<? extends FullHttpRequest>,FullHttpResponse>
DispatchMonoHandler
that expects RequestWithMetadata
<? extends
FullHttpRequest
>
messages and sends FullHttpResponse
s downstream.
HttpDispatchMonoHandler
handles Connection
HTTP header (a.k.a. keep-alive
) so that
RequestDispatcher
SHOULD NOT care about it.
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
ChannelHandler.Sharable
-
Constructor Summary
Constructors Constructor Description HttpDispatchMonoHandler(RequestDispatcher<RequestWithMetadata<? extends FullHttpRequest>,FullHttpResponse> dispatcher, long connectionIdleTimeoutMillis)
-
Method Summary
Modifier and Type Method Description void
channelRead(ChannelHandlerContext ctx, Object msg)
UsesRequestDispatcher
to process the request (msg
) and sends response downstream theChannelPipeline
.protected FullHttpResponse
failureResponse(RequestWithMetadata<? extends FullHttpRequest> request, Throwable failure)
Provides a response to send downstream if processing of therequest
has failed or some uncaughtThrowable
was thrown below in theChannelPipeline
.Methods inherited from class stincmale.server.netty4.tcp.DispatchMonoHandler
channelRegistered, closeChannelAfterResponse, exceptionCaught, fireExceptionOnResponseWriteFailure, getConnectionIdleTimeoutMillis, handlerRemoved, userEventTriggered
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelUnregistered, channelWritabilityChanged
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, isSharable
-
Constructor Details
-
HttpDispatchMonoHandler
public HttpDispatchMonoHandler(RequestDispatcher<RequestWithMetadata<? extends FullHttpRequest>,FullHttpResponse> dispatcher, long connectionIdleTimeoutMillis)- Parameters:
dispatcher
- SeeDispatchMonoHandler(RequestDispatcher, long)
.connectionIdleTimeoutMillis
- SeeDispatchMonoHandler(RequestDispatcher, long)
.
-
-
Method Details
-
channelRead
UsesRequestDispatcher
to process the request (msg
) and sends response downstream theChannelPipeline
. If response isnull
, then writesMonoHandler.VOID_OUTBOUND_MESSAGE
, which results in no response being actually sent. Does not propagatemsg
upstream.Calls ReferenceCounted.release() on the
msg
after completion of processing and sending a response ifmsg
isReferenceCounted
.Wraps
msg
intoRequestWithMetadata
if it's not already aRequestWithMetadata
.- Specified by:
channelRead
in interfaceChannelInboundHandler
- Overrides:
channelRead
in classDispatchMonoHandler<RequestWithMetadata<? extends FullHttpRequest>,FullHttpResponse>
- Throws:
Exception
-
failureResponse
protected FullHttpResponse failureResponse(@Nullable RequestWithMetadata<? extends FullHttpRequest> request, Throwable failure)Description copied from class:DispatchMonoHandler
Provides a response to send downstream if processing of therequest
has failed or some uncaughtThrowable
was thrown below in theChannelPipeline
. This method is called fromDispatchMonoHandler.channelRead(io.netty.channel.ChannelHandlerContext, java.lang.Object)
,DispatchMonoHandler.exceptionCaught(io.netty.channel.ChannelHandlerContext, java.lang.Throwable)
if currentChannel
is active.- Overrides:
failureResponse
in classDispatchMonoHandler<RequestWithMetadata<? extends FullHttpRequest>,FullHttpResponse>
- Parameters:
request
- Provided if available.failure
- AThrowable
that was thrown during processing therequest
,or during sending a response, or during some other operations related to therequest
or the currentChannel
.- Returns:
null
.
-