Current Behavior:
Currently, CROW_WEBSOCKET_ROUTE only supports a fixed signature for the onaccept handler:
onaccept(const crow::request&, std::optionalcrow::response&, void**)
Even if the route is defined with path parameters (e.g., /ws/), these parameters cannot be automatically injected into the handler arguments, unlike regular HTTP routes.
Not only is parameter injection missing in onaccept, but there is currently no way easily to retrieve the captured path parameters (e.g., from or ) at the WebSocket lifecycle.
Expected Behavior:
It would be highly beneficial if onaccept could support variadic arguments corresponding to the route parameters, for example:
CROW_WEBSOCKET_ROUTE(app, "/ws/<int>") .onaccept([](const crow::request &req, std::optional<crow::response> &res, void** userdata, int id) { // 'id' should be automatically parsed and injected });
Actual Behavior:
// This fails to compile with "no matching function for call to ...." CROW_WEBSOCKET_ROUTE(app, "/ws/<int>") .onaccept([](const crow::request& req, std::optional<crow::response>& res, void** userdata, int id) { // ... });
Environment:
Crow version: 1.3.2
Platform: ARM Linux
Current Behavior:
Currently, CROW_WEBSOCKET_ROUTE only supports a fixed signature for the onaccept handler:
onaccept(const crow::request&, std::optionalcrow::response&, void**)
Even if the route is defined with path parameters (e.g., /ws/), these parameters cannot be automatically injected into the handler arguments, unlike regular HTTP routes.
Not only is parameter injection missing in onaccept, but there is currently no way easily to retrieve the captured path parameters (e.g., from or ) at the WebSocket lifecycle.
Expected Behavior:
It would be highly beneficial if onaccept could support variadic arguments corresponding to the route parameters, for example:
CROW_WEBSOCKET_ROUTE(app, "/ws/<int>") .onaccept([](const crow::request &req, std::optional<crow::response> &res, void** userdata, int id) { // 'id' should be automatically parsed and injected });Actual Behavior:
// This fails to compile with "no matching function for call to ...." CROW_WEBSOCKET_ROUTE(app, "/ws/<int>") .onaccept([](const crow::request& req, std::optional<crow::response>& res, void** userdata, int id) { // ... });Environment:
Crow version: 1.3.2
Platform: ARM Linux