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

HotReload should be an ASGI app #2

Closed
florimondmanca opened this issue Apr 8, 2020 · 0 comments · Fixed by #3
Closed

HotReload should be an ASGI app #2

florimondmanca opened this issue Apr 8, 2020 · 0 comments · Fixed by #3

Comments

@florimondmanca
Copy link
Owner

HotReload should be an actual ASGI app that we can mount onto an app, instead of having to manually register its WebSocketEndpoint:

import arel
from starlette.applications import Starlette
from starlette.routing import Mount

hotreload = arel.HotReload("./path/to/files")

app = Starlette(
    routes=[Mount("/hot-reload", hotreload, name="hot-reload")],
    on_startup=[hotreload.startup],
    on_shutdown=[hot_reaload.shutdown],
)

Then the WebSocketEndpoint could be provided internally at /, so that the route name stays hot-reload, i.e. whatever is given to Mount.

Wouldn't remove the need to register event handlers (most frameworks don't support lifespan on sub-apps, eg see encode/starlette#649), but at least it's a bit less framework-specific surface.

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 a pull request may close this issue.

1 participant