pgjones / hypercorn

Hypercorn is an ASGI and WSGI Server based on Hyper libraries and inspired by Gunicorn.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I log username in access log?

nabheet opened this issue · comments

I have a Fast API application that uses Bearer tokens. Is there was way for me to provide hypercorn the username or some identifier of the user/service-account associated with the bearer token from Fast API? So that it can be logged in the access log.

EDIT 1: I just realized I could set a response header in fast api and have hypercorn log it in the access log. Is that the best way to accomplish this?

I think the response header would work. Although it might make more sense to access log in FastAPI rather than Hypercorn - there is a good discussion of options here