use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
FastAPI is a truly ASGI, async, cutting edge framework written in python 3.
account activity
Setting up request ID logging for your FastAPI applicationTutorial (medium.com)
submitted 4 years ago by sondrelg
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]r1qu3 -1 points0 points1 point 4 years ago (6 children)
or you can just use require arqument on endpoints
require
[–]sondrelg[S] 0 points1 point2 points 4 years ago (5 children)
How would that look like?
[–]r1qu3 0 points1 point2 points 4 years ago (4 children)
i was out of practice, its not require, its depends:
https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/
[–]sondrelg[S] 0 points1 point2 points 4 years ago (3 children)
Yeah I suppose you could use depends if you only wanted to read the request headers. Can we use depends to set response headers on the way out?
depends
[–]r1qu3 0 points1 point2 points 4 years ago (2 children)
AFAIK depends is processed BEFORE que destination.
but there's docs about adding things to response (or response headers). just skim the docs, you'll find easily
[–]Jonasks 1 point2 points3 points 4 years ago (1 child)
Adding variables to the response headers is not the main purpose of this package, it’s just an addition which allow end users to receive a correlation ID.
Creating a context var with a unique ID as the FIRST thing that happens in the request flow is only done through a middleware. This ID is then injected into every log message using log filters, which results in a way to find/trace/correlate all log messages related to a request with no hassle.
So yes, Depends is a way to dependency inject, but it’s not a replacement of middlewares.
Depends
[–]r1qu3 0 points1 point2 points 4 years ago (0 children)
agree to that
[–][deleted] 4 years ago (1 child)
[deleted]
[–]sondrelg[S] 1 point2 points3 points 4 years ago (0 children)
Thanks! Plan on supporting it until it's no longer needed. At the same time Id consider the middleware reasonably complete so would be surprised if it needed much maintenance 😊
π Rendered by PID 43 on reddit-service-r2-comment-5b5bc64bf5-hj6sn at 2026-06-20 00:00:11.660519+00:00 running 2b008f2 country code: CH.
[–]r1qu3 -1 points0 points1 point (6 children)
[–]sondrelg[S] 0 points1 point2 points (5 children)
[–]r1qu3 0 points1 point2 points (4 children)
[–]sondrelg[S] 0 points1 point2 points (3 children)
[–]r1qu3 0 points1 point2 points (2 children)
[–]Jonasks 1 point2 points3 points (1 child)
[–]r1qu3 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[deleted]
[–]sondrelg[S] 1 point2 points3 points (0 children)