@Override
    protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof HttpRequest){
            receivedBytes = msg.toString().length();
            HttpRequest req =  (HttpRequest) msg;

            // Handle a bad requests.
            if (!req.getDecoderResult().isSuccess()) {
                sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, BAD_REQUEST));
                return;
            }

            // Allow only GET methods.
            if (req.getMethod() != GET) {
                sendHttpResponse(ctx, req, new DefaultFullHttpResponse(HTTP_1_1, FORBIDDEN));
                return;
            }

            uri = req.getUri();


            if ("/".equals(req.getUri())){
                sendHttpResponse(ctx, req, messageReceived(Handler.startPage, ctx, req));
                return;
            }

            if ("/favicon.ico".equals(uri)){
                return;
            }

            if ("/hello".equals(req.getUri())){
                sendHttpResponse(ctx, req, messageReceived(Handler.helloPage, ctx, req));
                return;
            }

            if ((req.getUri()).startsWith("/redirect")){
                sendHttpResponse(ctx, req, messageReceived(Handler.redirectPage, ctx, req));
                return;
            }

            if ("/status".equals(req.getUri())){
                sendHttpResponse(ctx, req, messageReceived(Handler.statisticsPage, ctx, req));
                return;
            }

            sendHttpResponse(ctx, req, messageReceived(Handler.notFound, ctx, req));

        }
    }