yhirose / cpp-httplib

A C++ header-only HTTP/HTTPS server and client library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pre routing handler with body available (or a catch all route)

dahmadjid opened this issue · comments

I am trying to have a single handler that handles all incoming http requests regardless of path or method.
I couldnt find that a catch all route is supported. So i am using the pre_routing_handler. I found that the pre_routing_handler does not have the body available as that is read after the pre_routing_handler is done.

a solution would be:

  • adding set_pre_routing_handler_with_body
  • or a default_handler that gets routed to in case no other route is matched

I will be happy to do a pull request on either of them as they look straightforward enough to implement.

@dahmadjid could you implement set_pre_routing_handler_with_body and some unit tests? Thanks!