-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
refactor(routing)!: Refactor routes and route handlers #3386
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v3.0 #3386 +/- ##
==========================================
- Coverage 98.25% 98.22% -0.03%
==========================================
Files 322 322
Lines 14672 14454 -218
Branches 2332 2290 -42
==========================================
- Hits 14416 14198 -218
- Misses 117 119 +2
+ Partials 139 137 -2 ☔ View full report in Codecov by Sentry. |
Quality Gate passedIssues Measures |
Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/3386 |
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
* 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 <jacob@z7x.org> Co-authored-by: Peter Schutt <peter.github@proton.me>
Refactor routes and route handlers in an attempt to simplify configuration.
The two general goals here are:
In general I'd like to restrict the routes to an internal part of the ASGI routing, only taking care of mapping a path > route handler(s), and establishing the connection. Everything else should be taken care of by the handlers.
What this currently does:
handler_names
property fromHTTPRoute
OPTIONS
handler creation from theHTTPRoute
to the route registration processmethods
attribute fromBaseRoute
; It does not make sense on the asgi/websocket routesKwargsModel
from the routes to the handlers and remove the outside mutation of the handlersASGIConnection
/WebSocket
/Request
in the routes and pass them to handlers instead of raw ASGI objects (scope
,receive
,send
)