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

Method dispatch

starlette/endpoints.py:32–46  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

30 return self.dispatch().__await__()
31
32 async def dispatch(self) -> None:
33 request = Request(self.scope, receive=self.receive)
34 handler_name = "get" if request.method == "HEAD" and not hasattr(self, "head") else request.method.lower()
35
36 handler: Callable[[Request], Any]
37 if request.method in self._allowed_methods or (request.method == "HEAD" and "GET" in self._allowed_methods):
38 handler = getattr(self, handler_name)
39 else:
40 handler = self.method_not_allowed
41 is_async = is_async_callable(handler)
42 if is_async:
43 response = await handler(request)
44 else:
45 response = await run_in_threadpool(handler, request)
46 await response(self.scope, self.receive, self.send)
47
48 async def method_not_allowed(self, request: Request) -> Response:
49 # If we're running inside a starlette application then raise an

Callers 1

__await__Method · 0.95

Calls 3

RequestClass · 0.90
is_async_callableFunction · 0.90
run_in_threadpoolFunction · 0.90

Tested by

no test coverage detected