本文整理匯總了Python中channels.routing.URLRouter方法的典型用法代碼示例。如果您正苦於以下問題:Python routing.URLRouter方法的具體用法?Python routing.URLRouter怎麽用?Python routing.URLRouter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類channels.routing
的用法示例。
在下文中一共展示了routing.URLRouter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: _prepare_ws_urlpatterns
# 需要導入模塊: from channels import routing [as 別名]
# 或者: from channels.routing import URLRouter [as 別名]
def _prepare_ws_urlpatterns(app_set):
"""
Generate WS URL patterns for the given list of tuples of apps and
configuration objects
:param app_set: the given list of tuples of apps and their configuration
objects
:return: the WS URL patterns
"""
ws_urlpatterns = list()
for (app, app_configuration) in app_set:
if app_configuration.is_allowed:
url = app_configuration.base_urls.ws
if url is not None:
module = importlib.import_module(f'{app}.ws_urls')
dictionary = module.__dict__
app_urlpatterns = dictionary['urlpatterns']
url_router = URLRouter(app_urlpatterns)
ws_urlpatterns.append(
path(url, url_router)
)
return ws_urlpatterns
示例2: get_protocol_type_router
# 需要導入模塊: from channels import routing [as 別名]
# 或者: from channels.routing import URLRouter [as 別名]
def get_protocol_type_router(self, tenant_prefix, ws_urlconf):
"""
Subclasses can override this to include more protocols.
"""
return TenantAwareProtocolTypeRouter(
{"websocket": TenantAuthMiddlewareStack(URLRouter(ws_urlconf))}, tenant_prefix
)