@Override
public void messageReceived(final ChannelHandlerContext ctx,
final FullHttpRequest msg) throws Exception {
// Create request handler
final RequestHandlerMapping mapping =
config.getRequestMapping(msg.getUri());
if (mapping == null) {
sendNotFound(ctx, msg);
return;
}
final String relativePath =
msg.getUri().substring(mapping.path().length());
// Create request/response
final PooledServerRequest request = messagePool.getRequest();
// Handle 503 - sanity check, should be caught in acceptor
if (request == null) {
sendServerError(ctx, new ServerTooBusyException(
"Maximum concurrent connections reached"));
return;
}
request.init(ctx.channel(), msg, relativePath);
final RequestHandler handler = mapping.handler(request);
final PooledServerResponse response = messagePool.getResponse();
response.init(ctx, this, handler, request, config.logger());
// Store in ChannelHandlerContext for future reference