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
Is your feature request related to a problem? Please describe.
There are times where individual filters want to work on the same object obtained by one of the previous filters, for example a Logged In filter may guarantee that there is a user object in memory for subsequent filters to make use of.
Now since subsequent filters have no knowledge or context awareness of the previous filters, they have to pull that object from memory somewhere each time, which requires a mutex and a map that contains the desired object.
This creates redundant lookups for the object in each subsequent filter, which was already obtained by the Logged In filter.
Describe the solution you'd like
Add a 4th parameter to filters, std::any& context, which the first filter sets it to the desired object, and subsequent filters will access that 4th parameter to perform their checks on.
The structure of this method may look like the following in the framework:
There's also another way to do this without breaking compatibility with old code using the 3 parameter filters, by adding the context into the request objects themselves, which now will look identical to WebSocketConnection's contexts.
Describe alternatives you've considered
I am aware of drogon::HttpRequest Attribute's existence, but its data type is std::map and involves a lookup anyway.
The text was updated successfully, but these errors were encountered:
Yeah you're right, my concern is with the lookup, to achieve best performance one has to do req->attributes().insert("", std::move(someObject));
This is to help with the speed of the lookup
Compared to a std::any_cast on a context member it may be debatable which one looks more user friendly, it's not a significant issue
Is your feature request related to a problem? Please describe.
There are times where individual filters want to work on the same object obtained by one of the previous filters, for example a Logged In filter may guarantee that there is a user object in memory for subsequent filters to make use of.
Now since subsequent filters have no knowledge or context awareness of the previous filters, they have to pull that object from memory somewhere each time, which requires a mutex and a map that contains the desired object.
This creates redundant lookups for the object in each subsequent filter, which was already obtained by the Logged In filter.
Describe the solution you'd like
Add a 4th parameter to filters,
std::any& context
, which the first filter sets it to the desired object, and subsequent filters will access that 4th parameter to perform their checks on.The structure of this method may look like the following in the framework:
There's also another way to do this without breaking compatibility with old code using the 3 parameter filters, by adding the context into the request objects themselves, which now will look identical to
WebSocketConnection
's contexts.Describe alternatives you've considered
I am aware of
drogon::HttpRequest
Attribute's existence, but its data type isstd::map
and involves a lookup anyway.The text was updated successfully, but these errors were encountered: