-
-
Notifications
You must be signed in to change notification settings - Fork 439
Middleware doesn't work when added through the constructor #861
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
after_handle
not executed when adding middleware through the constructor
Also an FYI, in middleware.h, in the |
From looking at the source, I think the middlewares passed to the constructor replace those defined in the template arguments as an alternative initialization to the MyMiddleware middleware;
// configure middleware
crow::App<MyMiddleware> app(middleware);
// define routes
app.bindaddr("127.0.0.1").port(8080).run(); If this is correct, it would sure be useful to have a I'll try to submit a PR when I get time. |
unluckily PR is stuck in draft state. |
Yeah, life stuff. Feel free to close them. I'll reopen them one day if I manage to get it over the line. |
I noticed a strange behaviour when playing around with middlewares, when I add my middleware to the app as a template argument it works as expected, however, when I add the same middleware as a constructor argument, neither
before_handle
andafter_handle
are executed.I added a log to the
after_handle
function:Compiling and running the following:
Sending a single request prints "wtf?!" as expected:
However, if I compile and run the following:
And send a single request, I don't get the "wtf?!" message:
The reference docs Say about the constructor "Construct Crow with a subset of middleware.", what does that mean exactly? Can this be mentioned in the Middleware guide?
The text was updated successfully, but these errors were encountered: