Package org.aesh.terminal.http.netty
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
ConstructorsConstructorDescriptionHttpRequestHandler(String wsUri) 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 TypeMethodDescriptionprotected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, io.netty.handler.codec.http.FullHttpRequest request) voidexceptionCaught(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, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Constructor Details
-
HttpRequestHandler
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
Creates a new HTTP request handler with the specified WebSocket URI and resource path.- Parameters:
wsUri- the URI path for WebSocket upgrade requestsresourcePath- 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:
channelRead0in classio.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:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Parameters:
ctx- the channel handler contextcause- the exception that was caught- Throws:
Exception- if an error occurs during handling
-