FastAPI 0.68.0
Python 3.8
from fastapi import Depends, FastAPI, Header, HTTPException
async def verify_key(x_key: str = Header(...)):
if x_key != "fake-super-secret-key":
raise HTTPException(status_code=400, detail="X-Key header invalid")
return x_key
app = FastAPI(dependencies=[Depends(verify_key)])
@app.get("/items/")
async def read_items():
return [{"item": "Portal Gun"}, {"item": "Plumbus"}]
This is a example from FastAPI doucuments (Omit part of the code)
Is there any way to get x_key in read_items()