We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Middlewares registered with app.register_named_middleware don't seem to work.
# playground.py from sanic import Sanic, text app = Sanic("my-app") @app.get("/test", name="test") def test(request): return text("This is response") async def middleware(request): print("This is middleware") app.register_named_middleware(middleware, ["test"])
Running sanic playground:app --host=0.0.0.0 --port=8000 --workers=1 and initiate a GET to 0.0.0.0:8000 is expected to emit a print in console.
sanic playground:app --host=0.0.0.0 --port=8000 --workers=1
Sanic CLI
MacOS
24.6.0
No response
The text was updated successfully, but these errors were encountered:
I think you need to add @app.on_request to your middleware function.
@app.on_request
@app.on_request async def middleware(request): print("This is middleware")
Sorry, something went wrong.
No branches or pull requests
Is there an existing issue for this?
Describe the bug
Middlewares registered with app.register_named_middleware don't seem to work.
Code snippet
Expected Behavior
Running
sanic playground:app --host=0.0.0.0 --port=8000 --workers=1
and initiate a GET to 0.0.0.0:8000 is expected to emit a print in console.How do you run Sanic?
Sanic CLI
Operating System
MacOS
Sanic Version
24.6.0
Additional context
No response
The text was updated successfully, but these errors were encountered: