Skip to content

Commit

Permalink
rename, add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
byewokko committed Oct 16, 2024
1 parent 901e385 commit 6694cc0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions asab/web/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,17 @@ def __init__(self, websvc: WebService, config_section_name: str, config: typing.
self.add_preflight_handlers(preflight_paths)

@aiohttp.web.middleware
async def store_request_in_context(request, handler):
async def set_request_context(request: aiohttp.web.Request, handler):
"""
Make sure that the incoming aiohttp.web.Request is available via Request context variable
"""
request_ctx = Request.set(request)
try:
return await handler(request)
finally:
Request.reset(request_ctx)

self.WebApp.middlewares.append(store_request_in_context)
self.WebApp.middlewares.append(set_request_context)


async def _start(self, app: Application):
Expand Down

0 comments on commit 6694cc0

Please sign in to comment.