@Override
    protected void decode(final ChannelHandlerContext ctx, final FullHttpRequest req, final List<Object> objects) throws Exception {
        ctx.channel().attr(StateKey.REQUEST_HEADERS).set(req.headers());

        final String acceptMime = Optional.ofNullable(req.headers().get(HttpHeaderNames.ACCEPT)).orElse("application/json");
        final Pair<String, MessageSerializer<?>> serializer = chooseSerializer(acceptMime);

        if (req.method() != POST) {
            sendError(ctx, METHOD_NOT_ALLOWED, METHOD_NOT_ALLOWED.toString());
            return;
        }

        if (null == serializer) {
            sendError(ctx, BAD_REQUEST, String.format("no serializer for requested Accept header: %s", acceptMime));
            return;
        }

        final RequestMessage requestMessage;
        try {
            requestMessage = getRequestMessageFromHttpRequest(req, serializers);
        } catch (IllegalArgumentException | SerializationException | NullPointerException ex) {
            sendError(ctx, BAD_REQUEST, ex.getMessage());
            return;
        }

        // checked in getRequestMessageFromHttpRequest
        ctx.channel().attr(StateKey.SERIALIZER).set(Pair.with(serializer.getValue0(), serializer.getValue1()));
        objects.add(requestMessage);
    }
A generic mapper to decode an application/json request.
gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/handler/HttpRequestMessageDecoder.java