etr/libhttpserver

Use std::function for not_found and other callbacks instead of function pointers.

stuart-byma opened this issue · 1 comments

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;

etr commented

This sounds like an excellent idea. I have just kicked off the checks on your PR.