litestar-org / litestar

Production-ready, Light, Flexible and Extensible ASGI API framework | Effortlessly Build Performant APIs
https://litestar.dev/
MIT License
5.57k stars 379 forks source link

Enhancement: Support dependencies in Guards #1129

Open provinzkraut opened 1 year ago

provinzkraut commented 1 year ago

Originally discussed n https://github.com/starlite-api/starlite/issues/1116#issuecomment-1411744192

If we add guards into the dependency graph, it would allow them to receive the same kwargs as dependencies as well, making them more convenient to use since they can opt to receive things such as query params, cookies and headers as needed, without having to go through the ASGIConnection.

Making the same data available in route handlers, dependencies and guards also makes for a better DX imo, since it's a bit more intuitive.


[!NOTE]
While we are open for sponsoring on GitHub Sponsors and OpenCollective, we also utilize Polar.sh to engage in pledge-based sponsorship.

Check out all issues funded or available for funding on our Polar.sh dashboard

  • If you would like to see an issue prioritized, make a pledge towards it!
  • We receive the pledge once the issue is completed & verified
  • This, along with engagement in the community, helps us know which features are a priority to our users.

Fund with Polar

Goldziher commented 1 year ago

After looking into this - it will be both complex to do, and will probably degrade performance. I dont think we should proceed with this - the current design is sufficent IMO.