Skip to content

Add websocket.handler.before/after/exception signals#2841

Merged
ahopkins merged 2 commits into
mainfrom
websocket-signals
Nov 28, 2023
Merged

Add websocket.handler.before/after/exception signals#2841
ahopkins merged 2 commits into
mainfrom
websocket-signals

Conversation

@Tronic

@Tronic Tronic commented Oct 20, 2023

Copy link
Copy Markdown
Member

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

codecov Bot commented Oct 20, 2023

Copy link
Copy Markdown

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

Tronic commented Oct 20, 2023

Copy link
Copy Markdown
Member Author

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

Comment thread sanic/app.py
@ahopkins ahopkins merged commit d1fc867 into main Nov 28, 2023
@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