code: public static <T> Middleware<AsyncHandler<T>, AsyncHandler<Response<ByteString>>>
    jsonSerialize(ObjectWriter objectWriter) {
     return handler ->
         requestContext -> handler.invoke(requestContext)
             .thenApply(result -> Response
                 .forPayload(serialize(objectWriter, result))
                 .withHeader(CONTENT_TYPE, JSON));
    }
docs: Middleware that serializes the result of the inner handler using the supplied
  {@link ObjectWriter}, and sets the Content-Type header to application/json.