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