[Web OpenAPI] How to stream Request body content?

31 views
Skip to first unread message

David P

unread,
May 31, 2022, 8:19:59 AMMay 31
to vert.x
Hello,

We are using  Web OpenAPI to build a router from an OpenAPI file.
In this API there is an operation which Request body content type is "application/octet-stream"

We would like to use the Request body as readStream (for piping,..)

The BodyHandler seems to be mandated by  WebOpenAPI. So the Body is fully read before our own handler is called :(

How could we disable this body handling?
Could we use an custom BodyHandler?

Thanks
David

Bruno F

unread,
Jun 1, 2022, 2:06:59 PMJun 1
to vert.x
Hi,

I'm not sure if it's going to work, but you might try to create your own body handler that would call a real body handler... or not:


public class MaybeBodyHandler implements BodyHandler {

    private final BodyHandler realBodyHandler;

    public MaybeBodyHandler(BodyHandler realBodyHandler) {
        this.realBodyHandler = realBodyHandler;
    }

    @Override
    public void handle(RoutingContext context) {
        boolean skip = something based on the request url or content type?
        if (skip) {
            context.next();
        } else {
            realBodyHandler.handle(context);
        }

    }

    // many @Override throwing "not implemented"

}

And register it using a rootHandler:

Bruno.
Reply all
Reply to author
Forward
0 new messages