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

Function sync_wrapper

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

Source from the content-addressed store, hash-verified

80 # Handle sync request/response functions.
81 @functools.wraps(func)
82 def sync_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> Any:
83 request = kwargs.get("request", args[idx] if idx < len(args) else None)
84 assert isinstance(request, Request), (
85 f"Parameter with name 'request' is required to be of type 'Request' not '{type(request).__name__}'"
86 )
87
88 if not has_required_scope(request, scopes_list):
89 if redirect is not None:
90 orig_request_qparam = urlencode({"next": str(request.url)})
91 next_url = f"{request.url_for(redirect)}?{orig_request_qparam}"
92 return RedirectResponse(url=next_url, status_code=303)
93 raise HTTPException(status_code=status_code)
94 return func(*args, **kwargs)
95
96 return sync_wrapper
97

Callers

nothing calls this directly

Calls 6

RedirectResponseClass · 0.90
HTTPExceptionClass · 0.90
has_required_scopeFunction · 0.85
funcFunction · 0.85
getMethod · 0.45
url_forMethod · 0.45

Tested by

no test coverage detected