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 websocket.handler.before/after/exception signals #2841

Merged
merged 2 commits into from
Nov 28, 2023
Merged

Conversation

Tronic
Copy link
Member

@Tronic Tronic commented Oct 20, 2023

Adding ability to implement middleware functionality on WebSocket handlers by signals that receive websocket parameter.

The flow is:

http.handler.before (request) -> websocket.handler.before (request, websocket) -> handler
 ____________________________________________________________________________________/
|
| -> clean exit: websocket.handler.after (request, websocket)
| -> except Exception: websocket.handler.exception (request, websocket, exception)
| -> cancelled/closed: no signal
                             |
                      any of the above -> http.handler.after(request)

@Tronic Tronic requested a review from a team as a code owner October 20, 2023 21:48
@codecov
Copy link

codecov bot commented Oct 20, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (45e1fc8) 88.306% compared to head (50cec6b) 88.452%.

❗ Current head 50cec6b differs from pull request most recent head 469803d. Consider uploading reports for the commit 469803d to get more accurate results

Additional details and impacted files
@@              Coverage Diff              @@
##              main     #2841       +/-   ##
=============================================
+ Coverage   88.306%   88.452%   +0.146%     
=============================================
  Files           92        92               
  Lines         7158      7162        +4     
  Branches      1229      1228        -1     
=============================================
+ Hits          6321      6335       +14     
+ Misses         582       573        -9     
+ Partials       255       254        -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Tronic
Copy link
Member Author

Tronic commented Oct 20, 2023

Diagram created by ChatGPT based on the ASCII sketch in OP.

sanic/app.py Show resolved Hide resolved
@ahopkins ahopkins merged commit d1fc867 into main Nov 28, 2023
24 checks passed
@ahopkins ahopkins deleted the websocket-signals branch November 28, 2023 13:36
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.

2 participants