-
-
Notifications
You must be signed in to change notification settings - Fork 387
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
feat!: static handler configuration [WIP] #3900
base: v3.0
Are you sure you want to change the base?
Conversation
* remove handler names * Remove option handler creation from HTTPRoute * Remove methods attribute from BaseRoute * Move kwargs model to handlers and creation to on_registration * Store kwargs model on handlers instead of routes * Simplify HTTPRoute route_handler_map creation * Simplify Router.route_handler_method_map * Relax typing of HTTPRoute * Move handling logic to route handlers * Remove scope_type * Don't pass route to HTTPRouteHandler during handling * Don't pass scope to handle methods * Resolve and establish connections in routes; Only pass connections to handlers --------- Co-authored-by: Jacob Coffee <[email protected]> Co-authored-by: Peter Schutt <[email protected]>
* make route handlers functional decorators
* remove handler names * Remove option handler creation from HTTPRoute * Remove methods attribute from BaseRoute * Move kwargs model to handlers and creation to on_registration * Store kwargs model on handlers instead of routes * Simplify HTTPRoute route_handler_map creation * Simplify Router.route_handler_method_map * Relax typing of HTTPRoute * Move handling logic to route handlers * Remove scope_type * Don't pass route to HTTPRouteHandler during handling * Don't pass scope to handle methods * Resolve and establish connections in routes; Only pass connections to handlers --------- Co-authored-by: Jacob Coffee <[email protected]> Co-authored-by: Peter Schutt <[email protected]>
* Remove deprecated StaticFiles and StaticFilesConfig * remove special casing of static files app from handlers/router * remove outdated docs sections * Add what's new section * Rename tests for consistency
* remove handler names * Remove option handler creation from HTTPRoute * Remove methods attribute from BaseRoute * Move kwargs model to handlers and creation to on_registration * Store kwargs model on handlers instead of routes * Simplify HTTPRoute route_handler_map creation * Simplify Router.route_handler_method_map * Relax typing of HTTPRoute * Move handling logic to route handlers * Remove scope_type * Don't pass route to HTTPRouteHandler during handling * Don't pass scope to handle methods * Resolve and establish connections in routes; Only pass connections to handlers --------- Co-authored-by: Jacob Coffee <[email protected]> Co-authored-by: Peter Schutt <[email protected]>
* make route handlers functional decorators
* Trigger documentation build * Trigger documentation build * docs: update to v3 style * docs: move some things to litestar.dev repo, change versioning, add environment tag * docs: update landing page * chore: update lockfile * chore: add AA upper constraint * fix(docs): re-colonize * docs: enable sphinx-togglebutton * docs: use current year var * deps: update deps * fix(docs): do not link __name__ for now * fix(docs): use correct link to page --------- Co-authored-by: Peter Schutt <[email protected]>
* remove handler names * Remove option handler creation from HTTPRoute * Remove methods attribute from BaseRoute * Move kwargs model to handlers and creation to on_registration * Store kwargs model on handlers instead of routes * Simplify HTTPRoute route_handler_map creation * Simplify Router.route_handler_method_map * Relax typing of HTTPRoute * Move handling logic to route handlers * Remove scope_type * Don't pass route to HTTPRouteHandler during handling * Don't pass scope to handle methods * Resolve and establish connections in routes; Only pass connections to handlers --------- Co-authored-by: Jacob Coffee <[email protected]> Co-authored-by: Peter Schutt <[email protected]>
* Remove deprecated StaticFiles and StaticFilesConfig * remove special casing of static files app from handlers/router * remove outdated docs sections * Add what's new section * Rename tests for consistency
* Trigger documentation build * Trigger documentation build * docs: update to v3 style * docs: move some things to litestar.dev repo, change versioning, add environment tag * docs: update landing page * chore: update lockfile * chore: add AA upper constraint * fix(docs): re-colonize * docs: enable sphinx-togglebutton * docs: use current year var * deps: update deps * fix(docs): do not link __name__ for now * fix(docs): use correct link to page --------- Co-authored-by: Peter Schutt <[email protected]>
* Trigger documentation build * Trigger documentation build * docs: update to v3 style * docs: move some things to litestar.dev repo, change versioning, add environment tag * docs: update landing page * chore: update lockfile * chore: add AA upper constraint * fix(docs): re-colonize * docs: enable sphinx-togglebutton * docs: use current year var * deps: update deps * fix(docs): do not link __name__ for now * fix(docs): use correct link to page --------- Co-authored-by: Peter Schutt <[email protected]>
* Remove deprecated StaticFiles and StaticFilesConfig * remove special casing of static files app from handlers/router * remove outdated docs sections * Add what's new section * Rename tests for consistency
* remove handler names * Remove option handler creation from HTTPRoute * Remove methods attribute from BaseRoute * Move kwargs model to handlers and creation to on_registration * Store kwargs model on handlers instead of routes * Simplify HTTPRoute route_handler_map creation * Simplify Router.route_handler_method_map * Relax typing of HTTPRoute * Move handling logic to route handlers * Remove scope_type * Don't pass route to HTTPRouteHandler during handling * Don't pass scope to handle methods * Resolve and establish connections in routes; Only pass connections to handlers --------- Co-authored-by: Jacob Coffee <[email protected]> Co-authored-by: Peter Schutt <[email protected]>
* make route handlers functional decorators
* remove handler names * Remove option handler creation from HTTPRoute * Remove methods attribute from BaseRoute * Move kwargs model to handlers and creation to on_registration * Store kwargs model on handlers instead of routes * Simplify HTTPRoute route_handler_map creation * Simplify Router.route_handler_method_map * Relax typing of HTTPRoute * Move handling logic to route handlers * Remove scope_type * Don't pass route to HTTPRouteHandler during handling * Don't pass scope to handle methods * Resolve and establish connections in routes; Only pass connections to handlers --------- Co-authored-by: Jacob Coffee <[email protected]> Co-authored-by: Peter Schutt <[email protected]>
* make route handlers functional decorators
* remove handler names * Remove option handler creation from HTTPRoute * Remove methods attribute from BaseRoute * Move kwargs model to handlers and creation to on_registration * Store kwargs model on handlers instead of routes * Simplify HTTPRoute route_handler_map creation * Simplify Router.route_handler_method_map * Relax typing of HTTPRoute * Move handling logic to route handlers * Remove scope_type * Don't pass route to HTTPRouteHandler during handling * Don't pass scope to handle methods * Resolve and establish connections in routes; Only pass connections to handlers --------- Co-authored-by: Jacob Coffee <[email protected]> Co-authored-by: Peter Schutt <[email protected]>
* make route handlers functional decorators
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v3.0 #3900 +/- ##
==========================================
- Coverage 98.30% 97.98% -0.32%
==========================================
Files 340 340
Lines 15209 15171 -38
Branches 1672 1641 -31
==========================================
- Hits 14951 14866 -85
- Misses 127 169 +42
- Partials 131 136 +5 ☔ View full report in Codecov by Sentry. |
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
Experimental branch. Very much work in progress.
Basic idea is this: Instead of mutating handlers in place, treat them as static configuration objects. Once the handler tree has been collected, reduce all the layers into a single handler by recursively merging them.
Why? The idea is that this design is much less error prone and easier to follow (e.g. a lot of things currently need to happen in a specific order, otherwise they'll break). It also supports a pattern we're using in a few places now (websocket listeners + stream), where you essentially want to replace the handler with a new one. Another benefit is that this can get rid of all the deep copying we're currently doing :)
Goals
Router
toLitestar
instanceresolve_
methodsdeepcopy
ing of route handlers during registration