Replies: 1 comment 1 reply
-
It's certainly possible. You can find the bounds your fn needs to fulfill here and below (that one is the one you need though if your closure takes just one argument before In your specific example, 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
-
Summary
This is probably more of a rust question than an axum question...
I can make middleware::from_fn work with a closure e.g. (
layer(middleware::from_fn(|r, n| do_something(r, n, "test")))
, but I can't figure how to please the rust type system in order to make a "factory" for do_something, e.g. how to make this simplified code compile:It currently fails with:
I've tried to add a few more traits to the return type as well as the nightly impl_trait_in_fn_trait_return feature with "impl Future" instead of the pin box to no avail... Do you know if there's a way to do this?
Otherwise I'll stick to the explicit closure, I thought I had to be explicit about the types in there but as seen here something as short as
|r, n| foo(r, n, "something")
works so it's much shorter than my original code spelling everything outaxum version
tip of main branch
Beta Was this translation helpful? Give feedback.
All reactions