(request, call_next)
| 205 | |
| 206 | @app.middleware("http") |
| 207 | async def middleware(request, call_next): |
| 208 | response: StreamingResponse = await call_next(request) |
| 209 | response.headers["x-state"] = json.dumps(state.copy()) |
| 210 | return response |
| 211 | |
| 212 | |
| 213 | client = TestClient(app) |