Skip to content

Conversation

@aminalaee
Copy link
Contributor

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
Contributor Author

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

Copy link
Owner

@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 <[email protected]>

Co-authored-by: Amin Alaee <[email protected]>

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

3 participants