You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 and after_handle are executed.
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:
Guiorgy
changed the title
Middleware after_handle not executed when adding middleware through the constructor
Middleware doesn't work when added through the constructor
Aug 5, 2024
Also an FYI, in middleware.h, in the is_after_handle_arity_3_impl struct value is defined as a constexpr, while in is_before_handle_arity_3_impl as a const.
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 app.get_middleware() approach:
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: