MCPcopy Index your code
hub / github.com/fastapi/fastapi / custom_middleware

Function custom_middleware

tests/test_dependency_contextvars.py:23–28  ·  view source on GitHub ↗
(
    request: Request, call_next: Callable[[Request], Awaitable[Response]]
)

Source from the content-addressed store, hash-verified

21
22@app.middleware("http")
23async def custom_middleware(
24 request: Request, call_next: Callable[[Request], Awaitable[Response]]
25):
26 response = await call_next(request)
27 response.headers["custom"] = "foo"
28 return response
29
30
31@app.get("/user", dependencies=[Depends(set_up_request_state_dependency)])

Callers

nothing calls this directly

Calls 1

call_nextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…