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

Create a WebSocketAPIRoute class to support #166 #178

Merged
merged 7 commits into from
May 24, 2019
Merged

Create a WebSocketAPIRoute class to support #166 #178

merged 7 commits into from
May 24, 2019

Conversation

jekirl
Copy link
Contributor

@jekirl jekirl commented Apr 22, 2019

Initial work at adding dependencies to websocket routes (see #166 ). The way I added it in is probably less than ideal, but figured I would open the PR for now. Still to be done is adding in tests for other dependencies such as Security, Query, Cookie, etc...

@codecov
Copy link

codecov bot commented Apr 22, 2019

Codecov Report

Merging #178 into master will decrease coverage by 0.04%.
The diff coverage is 95.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #178      +/-   ##
==========================================
- Coverage     100%   99.95%   -0.05%     
==========================================
  Files         164      164              
  Lines        4035     4079      +44     
==========================================
+ Hits         4035     4077      +42     
- Misses          0        2       +2
Impacted Files Coverage Δ
fastapi/dependencies/utils.py 100% <100%> (ø) ⬆️
tests/test_ws_router.py 100% <100%> (ø) ⬆️
fastapi/routing.py 98.76% <88.88%> (-1.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8880c4c...caf616b. Read the comment docs.

@codecov
Copy link

codecov bot commented Apr 22, 2019

Codecov Report

Merging #178 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #178    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files         164    181    +17     
  Lines        4035   4500   +465     
======================================
+ Hits         4035   4500   +465
Impacted Files Coverage Δ
fastapi/applications.py 100% <100%> (ø) ⬆️
docs/src/websockets/tutorial001.py 100% <100%> (ø)
docs/src/websockets/tutorial002.py 100% <100%> (ø)
fastapi/routing.py 100% <100%> (ø) ⬆️
.../test_tutorial/test_websockets/test_tutorial002.py 100% <100%> (ø)
fastapi/dependencies/models.py 100% <100%> (ø) ⬆️
.../test_tutorial/test_websockets/test_tutorial001.py 100% <100%> (ø)
fastapi/dependencies/utils.py 100% <100%> (ø) ⬆️
tests/test_ws_router.py 100% <100%> (ø) ⬆️
fastapi/openapi/docs.py 100% <0%> (ø) ⬆️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8880c4c...d523236. Read the comment docs.

@tiangolo
Copy link
Owner

Nice! I'll review it soon.

@jekirl
Copy link
Contributor Author

jekirl commented May 1, 2019

I have a few more things I could add to the PR that we are using internally. i.e. pydantic validated message types for websocket input/output. But I am not sure if others would find that functionality useful.

@tiangolo
Copy link
Owner

Sounds very interesting. I think we could have some optional mechanism to do it (not enforcing it on all cases).

How does it look like? I mean, the code a developer writes using your extensions.

@jekirl
Copy link
Contributor Author

jekirl commented May 14, 2019

I will try to put together a sample project soon™ ...

@tiangolo tiangolo merged commit b087246 into tiangolo:master May 24, 2019
@jekirl
Copy link
Contributor Author

jekirl commented May 24, 2019

Circling back on this, been in our backlog. Semi tricky to separate out the functionality, but haven't forgotten about it!

@tiangolo
Copy link
Owner

tiangolo commented May 24, 2019

Cool! I just refactored this PR a bit, added docs, updated tests and merged.

I also started encode/starlette#527. Once (and if) it is accepted, it will allow us to raise inside WebSocket endpoints, sub-dependencies, and handle errors more cleanly.

This is just released in version 0.24.0, the new docs are here: https://fastapi.tiangolo.com/tutorial/websockets/

I'll update the internals to include encode/starlette#527 later, but this works already.

Thanks a lot for your work! 🎉 🚀 🌮

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.

None yet

2 participants