code: public static Middleware<AsyncHandler<?>, AsyncHandler<Response<ByteString>>> serialize(
        Serializer serializer) {
  
      return inner -> inner
          .map(Middlewares::ensureResponse)
          .flatMapSync(resp -> ctx -> serializePayload(serializer, ctx.request(), resp));
    }
docs: Middleware that applies the supplied serializer to the result of the inner handler,
  changing the payload and optionally the Content-Type header.
  
  This middleware is type-unsafe, and it might be better to write your own middleware that does
  serialization.