mirror of
https://github.com/fusion44/blitz_api.git
synced 2026-08-16 12:20:14 +02:00
fix: temporary unversion SSE channel
The SEE channel currently doesn't work with fastapi-versioned.
This commit is contained in:
parent
c673394fa8
commit
2fd3381521
1 changed files with 14 additions and 12 deletions
26
main.py
26
main.py
|
|
@ -17,8 +17,8 @@ from app.repositories.bitcoin import (
|
|||
register_bitcoin_status_gatherer,
|
||||
register_bitcoin_zmq_sub,
|
||||
)
|
||||
from app.repositories.system import register_hardware_info_gatherer
|
||||
from app.repositories.lightning import register_lightning_listener
|
||||
from app.repositories.system import register_hardware_info_gatherer
|
||||
from app.routers import apps, bitcoin, lightning, setup, system
|
||||
from app.sse_starlette import EventSourceResponse
|
||||
|
||||
|
|
@ -40,8 +40,16 @@ app.include_router(system.router)
|
|||
app.include_router(setup.router)
|
||||
|
||||
|
||||
connections = []
|
||||
|
||||
|
||||
app = VersionedFastAPI(
|
||||
app, version_format="{major}", prefix_format="/v{major}", enable_latest=True
|
||||
)
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def on_startup() -> None:
|
||||
async def on_startup():
|
||||
await redis_plugin.init_app(app, config=config)
|
||||
await redis_plugin.init()
|
||||
await register_all_handlers()
|
||||
|
|
@ -52,7 +60,10 @@ async def on_shutdown() -> None:
|
|||
await redis_plugin.terminate()
|
||||
|
||||
|
||||
connections = []
|
||||
@app.get("/")
|
||||
def index():
|
||||
# path operation function
|
||||
return {"data": "123"}
|
||||
|
||||
|
||||
@app.get("/sse/subscribe", status_code=status.HTTP_200_OK)
|
||||
|
|
@ -63,15 +74,6 @@ async def stream(
|
|||
return EventSourceResponse(subscribe(request, channel, redis))
|
||||
|
||||
|
||||
app = VersionedFastAPI(app, version_format="{major}", prefix_format="/v{major}")
|
||||
|
||||
|
||||
@app.get("/")
|
||||
def index():
|
||||
# path operation function
|
||||
return {"data": "123"}
|
||||
|
||||
|
||||
async def subscribe(request: Request, channel: str, redis: Redis):
|
||||
(sub,) = await redis.subscribe(channel=Channel(channel, False))
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue