Skip to content

Commit e1c597f

Browse files
committed
Set all the web routes in the base app
1 parent 21393e7 commit e1c597f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/socketio_app/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from typing import Union
22

33
import socketio
4-
from starlette.routing import Mount, Router
4+
from starlette.routing import Mount, Router, Route
55

66
from common import AppConfig, application_init
77
from socketio_app.namespaces.chat import ChatNamespace
@@ -20,7 +20,11 @@ def create_app(
2020
sio.register_namespace(ChatNamespace("/chat"))
2121

2222
# Render /docs endpoint using starlette, and all the rest handled with Socket.io
23-
routes = [Mount("/docs", routes=docs.routes, name="docs"), Mount("", app=socketio.ASGIApp(sio), name="socketio")]
23+
routes = [
24+
Route("/docs/asyncapi.json", docs.asyncapi_json, methods=["GET"]),
25+
Route("/docs", docs.get_asyncapi_html, methods=["GET"]),
26+
Mount("", app=socketio.ASGIApp(sio), name="socketio")
27+
]
2428

2529
# No need for whole starlette, we're rendering a simple couple of endpoints
2630
# https://www.starlette.io/routing/#working-with-router-instances

src/socketio_app/web_routes/docs.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from pydantic import BaseModel
44
from starlette.requests import Request
55
from starlette.responses import HTMLResponse, JSONResponse
6-
from starlette.routing import Route
76

87
from common import AppConfig
98
from common.asyncapi import get_schema
@@ -103,9 +102,3 @@ async def get_asyncapi_html(
103102
</html>
104103
"""
105104
)
106-
107-
108-
routes = [
109-
Route("/asyncapi.json", asyncapi_json, methods=["GET"]),
110-
Route("/", get_asyncapi_html, methods=["GET"]),
111-
]

0 commit comments

Comments
 (0)