sanic icon indicating copy to clipboard operation
sanic copied to clipboard

Revise middleware handling

Open ahopkins opened this issue 1 year ago • 2 comments

This PR aims to:

  • introduce an API to control middleware ordering
  • performance boost
@app.on_request(priority=99)
async def high_priority(request):
    ...

ahopkins avatar Aug 07 '22 19:08 ahopkins

Codecov Report

Base: 87.844% // Head: 70.943% // Decreases project coverage by -16.900% :warning:

Coverage data is based on head (09b59d3) compared to base (389363a). Patch coverage: 87.500% of modified lines in pull request are covered.

:exclamation: Current head 09b59d3 differs from pull request most recent head 38b4ccf. Consider uploading reports for the commit 38b4ccf to get more accurate results

Additional details and impacted files
@@              Coverage Diff               @@
##              main     #2521        +/-   ##
==============================================
- Coverage   87.844%   70.943%   -16.901%     
==============================================
  Files           78        70         -8     
  Lines         6466      5627       -839     
  Branches      1247       972       -275     
==============================================
- Hits          5680      3992      -1688     
- Misses         560      1465       +905     
+ Partials       226       170        -56     
Impacted Files Coverage Δ
sanic/request.py 48.989% <50.000%> (-45.896%) :arrow_down:
sanic/middleware.py 92.592% <92.592%> (ø)
sanic/mixins/middleware.py 97.435% <94.736%> (-2.565%) :arrow_down:
sanic/app.py 83.742% <100.000%> (-3.758%) :arrow_down:
sanic/signals.py 90.298% <100.000%> (-2.403%) :arrow_down:
sanic/cookies.py 41.558% <0.000%> (-58.442%) :arrow_down:
sanic/handlers.py 39.423% <0.000%> (-57.899%) :arrow_down:
sanic/http/http1.py 35.915% <0.000%> (-49.296%) :arrow_down:
sanic/response.py 42.487% <0.000%> (-47.136%) :arrow_down:
... and 44 more

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

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

codecov[bot] avatar Aug 07 '22 19:08 codecov[bot]

A lot more use cases to consider with some potential breaking changes. Will be safer to kick this one out until after LTS.

ahopkins avatar Sep 19 '22 19:09 ahopkins