Class NettyHttpServerHandler
java.lang.Object
io.netty5.channel.SimpleChannelInboundHandler<io.netty5.handler.codec.http.HttpRequest>
eu.cloudnetservice.driver.network.netty.http.NettyHttpServerHandler
- All Implemented Interfaces:
io.netty5.channel.ChannelHandler
@Internal
final class NettyHttpServerHandler
extends io.netty5.channel.SimpleChannelInboundHandler<io.netty5.handler.codec.http.HttpRequest>
The http server handler implementation responsible to handling http requests sent to the server and responding to
them.
- Since:
- 4.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate NettyHttpChannelprivate final HostAndPortprivate static final eu.cloudnetservice.common.log.Loggerprivate final NettyHttpServer -
Constructor Summary
ConstructorsConstructorDescriptionNettyHttpServerHandler(@NonNull NettyHttpServer nettyHttpServer, @NonNull HostAndPort connectedAddress) Constructs a new http server handler instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(@NonNull io.netty5.channel.ChannelHandlerContext ctx) voidchannelExceptionCaught(@NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull Throwable cause) voidchannelInactive(@NonNull io.netty5.channel.ChannelHandlerContext ctx) voidchannelReadComplete(@NonNull io.netty5.channel.ChannelHandlerContext ctx) private voidhandleMessage(@NonNull io.netty5.channel.Channel channel, @NonNull io.netty5.handler.codec.http.HttpRequest httpRequest) Handles an incoming http request, posting it to the correct handler while parsing everything from it beforehand.private booleanhandleMessage0(NettyHttpServer.HttpHandlerEntry httpHandlerEntry, @NonNull HttpContext context, @NonNull String fullPath, @NonNull String[] pathEntries, @NonNull String[] handlerPathEntries) Handles the incoming request and posts it the given handler if the data matches the settings of the handler.protected voidmessageReceived(@NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull io.netty5.handler.codec.http.HttpRequest msg) Methods inherited from class io.netty5.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty5.channel.ChannelHandler
bind, channelInboundEvent, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, handlerRemoved, isSharable, pendingOutboundBytes, read, register, sendOutboundEvent, shutdown, write
-
Field Details
-
LOGGER
private static final eu.cloudnetservice.common.log.Logger LOGGER -
nettyHttpServer
-
connectedAddress
-
channel
-
-
Constructor Details
-
NettyHttpServerHandler
public NettyHttpServerHandler(@NonNull @NonNull NettyHttpServer nettyHttpServer, @NonNull @NonNull HostAndPort connectedAddress) Constructs a new http server handler instance.- Parameters:
nettyHttpServer- the http server associated with this handler.connectedAddress- the listener host and port associated with this handler.- Throws:
NullPointerException- if the given server or host and port are null.
-
-
Method Details
-
channelActive
-
channelInactive
-
channelExceptionCaught
-
channelReadComplete
-
messageReceived
protected void messageReceived(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull io.netty5.handler.codec.http.HttpRequest msg) - Specified by:
messageReceivedin classio.netty5.channel.SimpleChannelInboundHandler<io.netty5.handler.codec.http.HttpRequest>
-
handleMessage
private void handleMessage(@NonNull @NonNull io.netty5.channel.Channel channel, @NonNull @NonNull io.netty5.handler.codec.http.HttpRequest httpRequest) Handles an incoming http request, posting it to the correct handler while parsing everything from it beforehand.- Parameters:
channel- the channel from which the request came.httpRequest- the decoded request to handle.- Throws:
NullPointerException- if the given channel or request is null.
-
handleMessage0
private boolean handleMessage0(@NonNull NettyHttpServer.HttpHandlerEntry httpHandlerEntry, @NonNull @NonNull HttpContext context, @NonNull @NonNull String fullPath, @NonNull @NonNull String[] pathEntries, @NonNull @NonNull String[] handlerPathEntries) Handles the incoming request and posts it the given handler if the data matches the settings of the handler.- Parameters:
httpHandlerEntry- the handler to post to if everything matches.context- the context of the request.fullPath- the full requested path.pathEntries- the entries one by one of the path uri.handlerPathEntries- the entries of the http handler.- Returns:
- true if the message was posted to the handler, false otherwise.
- Throws:
NullPointerException- if one of the given parameters is null.
-