-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathrouting.py
More file actions
25 lines (19 loc) · 826 Bytes
/
routing.py
File metadata and controls
25 lines (19 loc) · 826 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.sessions import SessionMiddlewareStack
from django.apps import apps
from django.urls import path
from .consumers import GraphQLSubscriptionConsumer
from .settings import graphql_ws_path
if apps.is_installed("django.contrib.auth"):
from channels.auth import AuthMiddlewareStack
else:
AuthMiddlewareStack = None
websocket_urlpatterns = [path(graphql_ws_path, GraphQLSubscriptionConsumer)]
application = ProtocolTypeRouter({"websocket": URLRouter(websocket_urlpatterns)})
session_application = ProtocolTypeRouter(
{"websocket": SessionMiddlewareStack(URLRouter(websocket_urlpatterns))}
)
if AuthMiddlewareStack:
auth_application = ProtocolTypeRouter(
{"websocket": AuthMiddlewareStack(URLRouter(websocket_urlpatterns))}
)