MCPcopy
hub / github.com/encode/starlette / websocket_wrapper

Function websocket_wrapper

starlette/authentication.py:46–56  ·  view source on GitHub ↗
(*args: _P.args, **kwargs: _P.kwargs)

Source from the content-addressed store, hash-verified

44 # Handle websocket functions. (Always async)
45 @functools.wraps(func)
46 async def websocket_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> None:
47 websocket = kwargs.get("websocket", args[idx] if idx < len(args) else None)
48 assert isinstance(websocket, WebSocket), (
49 "Parameter with name 'websocket' is required to be of type 'WebSocket'"
50 f" not '{type(websocket).__name__}'"
51 )
52
53 if not has_required_scope(websocket, scopes_list):
54 await websocket.close()
55 else:
56 await func(*args, **kwargs)
57
58 return websocket_wrapper
59

Callers

nothing calls this directly

Calls 4

has_required_scopeFunction · 0.85
funcFunction · 0.85
getMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected