Skip to content
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

Add convenience for dynamic changes to routing #2704

Merged
merged 12 commits into from
Mar 19, 2023
Merged

Add convenience for dynamic changes to routing #2704

merged 12 commits into from
Mar 19, 2023

Conversation

ahopkins
Copy link
Member

@ahopkins ahopkins commented Mar 2, 2023

When trying to add something in event listeners, you might run up against the routers having been finalized. This creates a convenience that allows dynamic changes in a slightly easier way.

@app.before_server_start
async def dynamic_router_changes(app: Sanic) -> None:
    app.add_route(...)
    app.register_middleware(...)

The above will not work in current version since routes, signals, and middleware have all been finalized. The change allows these runtime changes to occur implicitly.

Closes #2699


TODO

  • Tests

@ahopkins ahopkins requested a review from a team as a code owner March 2, 2023 10:35
@ahopkins ahopkins marked this pull request as draft March 2, 2023 10:36
@codecov
Copy link

codecov bot commented Mar 2, 2023

Codecov Report

Patch coverage: 100.000% and project coverage change: +0.029 🎉

Comparison is base (5ee36fd) 88.607% compared to head (2f8c05a) 88.637%.

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2704       +/-   ##
=============================================
+ Coverage   88.607%   88.637%   +0.029%     
=============================================
  Files           87        87               
  Lines         6820      6838       +18     
  Branches      1171      1176        +5     
=============================================
+ Hits          6043      6061       +18     
  Misses         535       535               
  Partials       242       242               
Impacted Files Coverage Δ
sanic/app.py 90.068% <100.000%> (+0.315%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ahopkins ahopkins marked this pull request as ready for review March 15, 2023 14:22
@ahopkins ahopkins merged commit 8f265b8 into main Mar 19, 2023
@ahopkins ahopkins deleted the amend branch March 19, 2023 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

request middleware not running when registered in a method since 22.9.0
2 participants