From: Andrii Hryniv Date: Fri, 28 Mar 2025 15:30:37 +0000 (+0200) Subject: Fix link title for contextvars.ContextVar (#2913) X-Git-Tag: 0.46.2~4 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=d278cafb96c082f4d0e4494fc717ffeb72e23ba8;p=thirdparty%2Fstarlette.git Fix link title for contextvars.ContextVar (#2913) --- diff --git a/docs/middleware.md b/docs/middleware.md index 01d0afcf..f7cc2393 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -297,7 +297,7 @@ around explicitly, rather than mutating the middleware instance. Currently, the `BaseHTTPMiddleware` has some known limitations: -- Using `BaseHTTPMiddleware` will prevent changes to [`contextlib.ContextVar`](https://docs.python.org/3/library/contextvars.html#contextvars.ContextVar)s from propagating upwards. That is, if you set a value for a `ContextVar` in your endpoint and try to read it from a middleware you will find that the value is not the same value you set in your endpoint (see [this test](https://github.com/encode/starlette/blob/621abc747a6604825190b93467918a0ec6456a24/tests/middleware/test_base.py#L192-L223) for an example of this behavior). +- Using `BaseHTTPMiddleware` will prevent changes to [`contextvars.ContextVar`](https://docs.python.org/3/library/contextvars.html#contextvars.ContextVar)s from propagating upwards. That is, if you set a value for a `ContextVar` in your endpoint and try to read it from a middleware you will find that the value is not the same value you set in your endpoint (see [this test](https://github.com/encode/starlette/blob/621abc747a6604825190b93467918a0ec6456a24/tests/middleware/test_base.py#L192-L223) for an example of this behavior). To overcome these limitations, use [pure ASGI middleware](#pure-asgi-middleware), as shown below.