Skip to content

Commit

Permalink
Fix injection when using HTTP_HANDLER_BEFORE (#137)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Hopkins <[email protected]>
  • Loading branch information
prryplatypus and ahopkins authored Nov 6, 2022
1 parent 6f04ab9 commit e7c720d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions sanic_ext/extensions/injection/injector.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@ async def finalize_injections(app: Sanic, _):
injection_signal: Event = app.ext.config.INJECTION_SIGNAL

@app.signal(injection_signal)
async def inject_kwargs(request, route, kwargs, **_):
async def inject_kwargs(request, **_):
nonlocal signature_registry

for name in (route.name, f"{route.name}_{request.method.lower()}"):
for name in (
request.route.name,
f"{request.route.name}_{request.method.lower()}",
):
injections = signature_registry.get(name)
if injections:
break

if injections:
injected_args = await gather_args(injections, request, **kwargs)
injected_args = await gather_args(
injections, request, **request.match_info
)
request.match_info.update(injected_args)


Expand Down

0 comments on commit e7c720d

Please sign in to comment.