Class HttpRequestHandler

java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
org.aesh.terminal.http.netty.HttpRequestHandler
All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler

public class HttpRequestHandler extends io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
Netty channel handler for processing HTTP requests and serving static resources.
Author:
Julien Viet
  • Nested Class Summary

    Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler

    io.netty.channel.ChannelHandler.Sharable
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new HTTP request handler with the specified WebSocket URI.
    HttpRequestHandler(String wsUri, String resourcePath)
    Creates a new HTTP request handler with the specified WebSocket URI and resource path.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.FullHttpRequest request)
     
    void
    exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause)
    Handles exceptions caught during channel processing by logging and closing the context.

    Methods inherited from class io.netty.channel.SimpleChannelInboundHandler

    acceptInboundMessage, channelRead

    Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter

    channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered

    Methods inherited from class io.netty.channel.ChannelHandlerAdapter

    ensureNotSharable, handlerAdded, handlerRemoved, isSharable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.netty.channel.ChannelHandler

    handlerAdded, handlerRemoved
  • Constructor Details

    • HttpRequestHandler

      public HttpRequestHandler(String wsUri)
      Creates a new HTTP request handler with the specified WebSocket URI. Uses the default resource path for static files.
      Parameters:
      wsUri - the URI path for WebSocket upgrade requests
    • HttpRequestHandler

      public HttpRequestHandler(String wsUri, String resourcePath)
      Creates a new HTTP request handler with the specified WebSocket URI and resource path.
      Parameters:
      wsUri - the URI path for WebSocket upgrade requests
      resourcePath - the classpath resource path for static files, or null to disable static file serving
  • Method Details

    • channelRead0

      protected void channelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.FullHttpRequest request) throws Exception
      Specified by:
      channelRead0 in class io.netty.channel.SimpleChannelInboundHandler<io.netty.handler.codec.http.FullHttpRequest>
      Throws:
      Exception
    • exceptionCaught

      public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception
      Handles exceptions caught during channel processing by logging and closing the context.
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelHandler
      Specified by:
      exceptionCaught in interface io.netty.channel.ChannelInboundHandler
      Overrides:
      exceptionCaught in class io.netty.channel.ChannelInboundHandlerAdapter
      Parameters:
      ctx - the channel handler context
      cause - the exception that was caught
      Throws:
      Exception - if an error occurs during handling