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 support for functools.partial in WebsocketRoute #1356

Merged
merged 3 commits into from Dec 11, 2021

Conversation

aminalaee
Copy link
Member

Fixes #1355.

import functools

from starlette.applications import Starlette
from starlette.routing import WebSocketRoute

async def handle_ws(websocket):
    pass

app = Starlette(debug=True, routes=[
    WebSocketRoute("/", functools.partial(handle_ws)),
])

Support for using functools.partial with Route is already added. This PR adds support for WebSocketRoute.

@aminalaee
Copy link
Member Author

I'll try to refactor the tests for partial Route tests.

Copy link
Sponsor Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Thanks @aminalaee ! 🎉

@Kludex Kludex merged commit 76cd611 into master Dec 11, 2021
@Kludex Kludex deleted the add-partial-ws-routes branch December 11, 2021 13:35
aminalaee added a commit that referenced this pull request Dec 13, 2021
Add support for functools.partial in WebsocketRoute (#1356)

* Add support for functools.partial in WebsocketRoute

* remove commented code

* Refactor tests for partian endpoint and ws

Fix snippet on config.md (#1358)

* Fix snippet on config.md

* Update docs/config.md

Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>

Co-authored-by: Amin Alaee <mohammadamin.alaee@gmail.com>

remove outdated test
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.

WebSocketRoute does not work with functools.partial
2 participants