In your http server you should have handler, that extended from ChannelInboundHandlerAdapter.
And there you overriding method: channelRead, something like this:
public class MyHttpServerHandler extends ChannelInboundHandlerAdapter{
private static final ObjectMapper JsonMapper = new ObjectMapper();
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
if (msg instanceof HttpRequest) {
LOG.info("I'm HttpRequest");
FullHttpRequest req = (FullHttpRequest) msg;
if (HttpHeaders.is100ContinueExpected(req)) {
ctx.write(new DefaultFullHttpResponse(HTTP_1_1, CONTINUE));
}
// here your json
ObjectNode data = parseData(req);
}
}
private ObjectNode parseData(FullHttpRequest req){
ObjectNode res;
try {
res = JsonMapper.readValue(req.content().toString(CharsetUtil.UTF_8), ObjectNode.class);
return res;
}
catch (IOException e) {
}
return null;
}
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
super.channelRegistered(ctx);
}
@Override
public void channelUnregistered(ChannelHandlerContext ctx) throws Exception {
super. channelUnregistered(ctx);
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.close();
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) {
ctx.flush();
}
}