drogonframework / drogon

Drogon: A C++14/17/20 based HTTP web application framework running on Linux/macOS/Unix/Windows
MIT License
11.44k stars 1.1k forks source link

Handle PreHandlingAdvice before Filtering #1903

Closed danielbaud closed 8 months ago

danielbaud commented 8 months ago

Is your feature request related to a problem? Please describe.

I made a filter which purpose is to filter IPs. For some projects, the app is behind a Load Balancer, which means the IP the app receives is the one from the Load Balancer To handle this scenario, I tried using the drogon::plugin::RealIpResolver My problem is that the plugin adds a PreHandlingAdvice which is executed after the filter, which means the filter does not have access to the (yet to be computed) real IP

Describe the solution you'd like A solution would be being able to do the filtering after doing the pre handling advices. Perhaps there is a way to already do it which I am not aware of?

Describe alternatives you've considered In the case of not being able to move the filtering process after the pre handling advice, I am considering to add to my filter code the bits from the plugin that would implement the logic that I need, and it wouldn't be a big inconvenience, although keeping the plugin would be nicer

an-tao commented 8 months ago

@danielbaud Thanks for your feedback. I think the best way to solve your problem is to move the RealIpResolver plugin to the PostRouting join point, I'll make a patch for this.

danielbaud commented 8 months ago

Thanks a lot for the reactivity! I'll try the patch once it's merged