Dependencies in Path Operation Decorators
Decorator-Level Dependencies
Section titled “Decorator-Level Dependencies”You can declare dependencies in the decorator itself — they won’t appear as function parameters:
from justapi import JustAPIApp, Depends
app = JustAPIApp()
def verify_api_key(): api_key = request.headers.get("X-API-Key") if api_key != "secret-key": raise HTTPException(status_code=403) return True
@app.get("/items/", dependencies=[Depends(verify_api_key)])def list_items(): return {"items": []}The verify_api_key runs before list_items, but list_items doesn’t receive the result as a parameter.
Useful For
Section titled “Useful For”- Authentication checks where the handler doesn’t need the result
- Logging or rate limiting
- Cross-cutting concerns that apply to many routes
See Also
Section titled “See Also”- Global Dependencies — app-wide deps
- Security — authentication patterns