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 Details

    • LOGGER

      private static final eu.cloudnetservice.common.log.Logger LOGGER
    • nettyHttpServer

      private final NettyHttpServer nettyHttpServer
    • connectedAddress

      private final HostAndPort connectedAddress
    • channel

      private NettyHttpChannel 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

      public void channelActive(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx)
    • channelInactive

      public void channelInactive(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx)
    • channelExceptionCaught

      public void channelExceptionCaught(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull Throwable cause)
    • channelReadComplete

      public void channelReadComplete(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx)
    • messageReceived

      protected void messageReceived(@NonNull @NonNull io.netty5.channel.ChannelHandlerContext ctx, @NonNull @NonNull io.netty5.handler.codec.http.HttpRequest msg)
      Specified by:
      messageReceived in class io.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.