CrowCpp / Crow

A Fast and Easy to use microframework for the web.
https://crowcpp.org
Other
3.3k stars 364 forks source link

Local Middleware Not Working with route_dynamic in Crow #933

Open rem0obb opened 3 weeks ago

rem0obb commented 3 weeks ago

I'm currently using Crow extensively for a project. After doing some research in the Crow repository and reviewing code and related issues, particularly Issue #717, I noticed a limitation: it seems that local middlewares cannot be applied using route_dynamic, especially when working with WebSocket protocols or standard web usage patterns.

For example:

app.route_dynamic(url)
   .middlewares<crow::App<middleware::websocket::JWTAuth>, middleware::websocket::JWTAuth>()
   .websocket(&app);

Based on my testing, the middleware isn’t properly applied within route_dynamic. This issue affects both WebSocket connections and regular web routes, making it difficult to implement route-specific logic like authentication or authorization using local middleware.