-
Notifications
You must be signed in to change notification settings - Fork 192
Description
Is your feature request related to a problem? Please describe.
I'm trying to set up self contained unit tests for a httpserver::http_resource
implementation but there doesn't seem to be any way to construct the arguments needed to invoke it without resorting to standing up a whole HTTP server which could be impractical or impossible depending on the environment that the test needs to run in (i.e. a restricted uses with no network or file system access) and even where possible forces otherwise unneeded dependencies on things like an HTTP client library.
Describe the solution you'd like
I'd like to be able to write something like:
std::unique_ptr<httpserver::http_request> req = httpserver::http_request_factory(HTTP_RESPONCE_TEXT);
auto resp = my_resource.render(*req);
// ... Test resp.
For more advanced usage (https, WebSockets, etc.) the sort of fluent interface that is used to create a httpserver::webserver
could be employed.
Describe alternatives you've considered
Looking at the test of httpserver
it self, it looks like it takes the "use a http client library" approach, but then again, it's testing the server so it has to do that.