Closed stuart-byma closed 1 year ago
This would allow passing contextual information directly to the not found (or other) handler via a lambda capture. Basic function pointers only support lambdas without captures.
I imagine this would be a drop in replacement of
typedef const std::shared_ptr<http_response>(*render_ptr)(const http_request&);
with
typedef std::function<const std::shared_ptr<http_response>(const http_request &)> render_ptr;
This sounds like an excellent idea. I have just kicked off the checks on your PR.
This would allow passing contextual information directly to the not found (or other) handler via a lambda capture. Basic function pointers only support lambdas without captures.
I imagine this would be a drop in replacement of
typedef const std::shared_ptr<http_response>(*render_ptr)(const http_request&);
with
typedef std::function<const std::shared_ptr<http_response>(const http_request &)> render_ptr;