`#[debug_handler]` for from_fn middleware
- [x] I have looked for existing issues (including closed) about this
Feature Request
I'd like for something like #[debug_handler] to work on from_fn middleware (which now supports extractors).
Motivation
Same motivation as debug_handler in the first place - you get arcane errors, particularly if you do the FromRequestParts extractors after the FromRequest extractor by mistake.
Proposal
This almost works out of box, but you get this error with code similar to the example code https://docs.rs/axum/latest/axum/middleware/fn.from_fn.html#example
error: `Request<_>` consumes the request body and thus must be the last argument to the handler function
--> crates/common/src/http/mod.rs:390:10
|
390 | req: http::request::Request<Body>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The issue is that middleware looks something like this, with the next arg
async fn my_middleware<B>(
request: Request<B>,
next: Next<B>,
) -> Response {
Alternatives
We could make a separate macro for middleware vs reusing the debug_handler macro. No strong preference either way.
Hey folks! This was merged a few months back, do you think it'd be reasonable to bump axum-macros to make this available?
cc @yanns @jplatte
Hey, unfortunately neither of us can do crates.io releases. We're going to have to wait for David to take care of this. I've pinged him about releases a while ago.
Thanks a lot, hope those will come soon 🙏
Don't we have debug_middleware for debugging middleware?
Yes, we just forgot to close this, thanks for the ping.