Tectu / malloy

A cross-platform C++20 library providing embeddable server & client components for HTTP and WebSocket.
BSD 3-Clause "New" or "Revised" License
68 stars 8 forks source link

Should sub-routers automatically remove trailing slash? #75

Closed Tectu closed 3 years ago

Tectu commented 3 years ago

When dealing with subrouters, one might have something like this:

sub_router->add(method::get, "", [this](const auto req&) { /* ... */ });
router->add_subrouter("/foo", sub_router);

When a user then navigates to http://<base_url>/foo/ the server will respond with 404 - The resource '' was not found..

I'm wondering whether sub-routers should automatically drop trailing slashes before handling a request. This needs to be checked against the HTTP specification.