_extract_endpoint_context() — fastapi Function Reference
Architecture documentation for the _extract_endpoint_context() function in routing.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 74570640_d48f_6978_d994_fcf56400f5f3["_extract_endpoint_context()"] de395a51_26f8_3424_1af0_2f5bef39c893["routing.py"] 74570640_d48f_6978_d994_fcf56400f5f3 -->|defined in| de395a51_26f8_3424_1af0_2f5bef39c893 ad8d62d9_53da_514b_c06f_53293eb1e5ae["get_request_handler()"] ad8d62d9_53da_514b_c06f_53293eb1e5ae -->|calls| 74570640_d48f_6978_d994_fcf56400f5f3 a0d87950_5de5_3ab2_72f7_0a20a6e00434["get_websocket_app()"] a0d87950_5de5_3ab2_72f7_0a20a6e00434 -->|calls| 74570640_d48f_6978_d994_fcf56400f5f3 style 74570640_d48f_6978_d994_fcf56400f5f3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
fastapi/routing.py lines 241–261
def _extract_endpoint_context(func: Any) -> EndpointContext:
"""Extract endpoint context with caching to avoid repeated file I/O."""
func_id = id(func)
if func_id in _endpoint_context_cache:
return _endpoint_context_cache[func_id]
try:
ctx: EndpointContext = {}
if (source_file := inspect.getsourcefile(func)) is not None:
ctx["file"] = source_file
if (line_number := inspect.getsourcelines(func)[1]) is not None:
ctx["line"] = line_number
if (func_name := getattr(func, "__name__", None)) is not None:
ctx["function"] = func_name
except Exception:
ctx = EndpointContext()
_endpoint_context_cache[func_id] = ctx
return ctx
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does _extract_endpoint_context() do?
_extract_endpoint_context() is a function in the fastapi codebase, defined in fastapi/routing.py.
Where is _extract_endpoint_context() defined?
_extract_endpoint_context() is defined in fastapi/routing.py at line 241.
What calls _extract_endpoint_context()?
_extract_endpoint_context() is called by 2 function(s): get_request_handler, get_websocket_app.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free