How to return headers on FastAPIController failures?
fgsalomon opened this issue · comments
Sometimes in addition of a status code and a detail message we also need to return some headers.
For example, in some authentication mechanism we could need to return a 401 error with a www-authenticate
header.
With pure FastAPI I would just do:
raise HTTPException(
status_code=401,
detail="Unauthorized",
headers={'WWW-Authenticate': 'authType="OTP"'},
)
How can we achieve this with Petisco's FastAPIController?