INNER CODE UNIT · Python
dispatch
leonh/redis-streams-fastapi-chat · chat.py:40
async def dispatch(self, request, call_next):
response = await call_next(request)
response.headers['Custom'] = self.header_value
return response
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
@asynccontextmanager
async def lifespan(app: FastAPI):
# Startup
try:
redis_url = f"redis://{REDIS_HOST}:{REDIS_PORT}"
pool = await aioredis.from_url(
redis_url,
encoding='utf-8',
decode_responses=True,
max_connections=20