lundi 11 février 2019

using different request parser depending on the queried route

I'm Implementing a mini http server using boost beast. the server has two different routes POST /upload/... and the other one is POST /info. The first one is used for uploading some big files and the other one is for hadling json objects. To keep the performance as hight as possible am I trying to parse each route with the suitable parser file_body and string_body/dynamic_body. I was hoping that it is possible to do something like:

http::async_read_header(
            socket_,
            buffer_,
            request_,
            [self](beast::error_code ec, std::size_t)
            {
                if (!ec)
                    self->request_.body().data();
            });

but it seems not possible. Is there any way to use different request bodies depending on header info? Many thanks in advance

Aucun commentaire:

Enregistrer un commentaire