glaze icon indicating copy to clipboard operation
glaze copied to clipboard

Templating http_router to allow broader re-use

Open nlescoua opened this issue 7 months ago • 1 comments

Glaze is really a great library, very versatile for json and other uses. The http_router is also very promising. Currently, the http_router assumes that handler = void(request&, response&). This is perfect for use in the context of glaze::http_server, and works for use with std::future. However, we believe that templating http_router

template<typename H = std::function<void(request&, response&)> class http_router { using handler = typename H; ... }

would be a great way to allow the use of http_router in other contexts (other futures implementations, coroutine-based servers, or even callback-based servers). Just get/put would make sense in this case, so get_async/put_async could be enabled/disabled using concepts so that they are present iff handler == std::function<void(request&, response&)>.

nlescoua avatar Jul 25 '25 14:07 nlescoua

I'm all for making the http_router more generic. Do you want to submit a pull request?

stephenberry avatar Jul 25 '25 21:07 stephenberry