ASGI Middleware helpers #453
Unanswered
martino87r
asked this question in
Q&A
Replies: 1 comment 1 reply
-
|
For middleware, the only good resources I know is the documentation.
You may also be able to just hook into the |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I'm currently struggling to create a simple middleware for a Quart project; although I know that what I want already exists I want to try to create it myself first to learn about the ASGI interface on a practical level.
I'm using HTMX so I want to create a middleware that checks the current headers for the
hx-requestand evetually pass the flag down to the request object.Ex:
request.state.htmxAccording to the source code, this seems actually impossible; I've also compared how
starlettedoes things and they provide nice wrappers for the ASGI middleware, providing parsers forrequestandheadersso you can manipulate them easily with the context of a generic ASGI middleware.The second middleware I wanted to implement is a tracing one to figure out various timings (ex. SQL queries, template rendering times etc.), but without docs or helpers I can't wrap my head around it.
Any tips or suggestions would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions