MCPcopy
hub / github.com/fastapi/fastapi / handle

Method handle

fastapi/routing.py:1246–1266  ·  view source on GitHub ↗
(self, scope: Scope, receive: Receive, send: Send)

Source from the content-addressed store, hash-verified

1244 return match, child_scope
1245
1246 async def handle(self, scope: Scope, receive: Receive, send: Send) -> None:
1247 effective_context = _get_scope_effective_route_context(scope)
1248 if effective_context is not None and effective_context.original_route is self:
1249 methods = effective_context.methods
1250 if methods and scope["method"] not in methods:
1251 headers = {"Allow": ", ".join(methods)}
1252 if "app" in scope:
1253 raise HTTPException(status_code=405, headers=headers)
1254 response = PlainTextResponse(
1255 "Method Not Allowed", status_code=405, headers=headers
1256 )
1257 await response(scope, receive, send)
1258 return
1259 token = _effective_route_context_var.set(effective_context)
1260 try:
1261 app = request_response(self.get_route_handler())
1262 finally:
1263 _effective_route_context_var.reset(token)
1264 await app(scope, receive, send)
1265 return
1266 await super().handle(scope, receive, send)
1267
1268
1269@dataclass

Callers 4

handleMethod · 0.45
_handle_selectedMethod · 0.45
handleMethod · 0.45
appMethod · 0.45

Calls 5

get_route_handlerMethod · 0.95
HTTPExceptionClass · 0.90
request_responseFunction · 0.85
appFunction · 0.85

Tested by

no test coverage detected