alice-biometrics / petisco

🍪 petisco is a framework for helping Python developers to build clean Applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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?