The netty provisions us to handle a request as a pipeline where you define the pipeline as a sequence of handlers.
One sequence could be like this:
p.addLast ("codec", new HttpServerCodec ());
p.addLast ("handler", new YourHandler());
where p is an instance of ChannelPipeline interface. You can define the YourHandler class as follows:
public class YourHandler extends ChannelInboundHandlerAdapter
{
@Override
public void channelRead (ChannelHandlerContext channelHandlerCtxt, Object msg)
throws Exception
{
// Handle requests as switch cases. GET, POST,...
// This post helps you to understanding switch case usage on strings:
// http://stackoverflow.com/questions/338206/switch-statement-with-strings-in-java
if (msg instanceof FullHttpRequest)
{
FullHttpRequest fullHttpRequest = (FullHttpRequest) msg;
switch (fullHttpRequest.getMethod ().toString ())
{
case "GET":
case "POST":
...
}
}
}
}