-
SummaryHello, I'm trying to implement a feature found in multiple web frameworks that allows POST forms to contain a I have successfully written a middleware .route(
"/channel/:channel",
get(channel_details)
.fallback_service(axum::middleware::from_fn(util_middleware::form_method_rewriter).layer(
post(channel_rename).delete(channel_delete),
)),
) Here's the trait resolution error I get:
I don't understand why FromFn is expected to implement I have a similar axum version0.7.7 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Solution: Adding |
Beta Was this translation helpful? Give feedback.
Solution:
I had a small misunderstanding,
FromFn
is a service and should definitely implement theService
trait. I was confusing it withFromFnLayer
.FromFn: Service
wasn't satisfied because the service I was wrapping inside my layer (aMethodRouter
) didn't actually implementService
for a reason that was clearly documented 🥴 (it had an explicit app state bound to it, which I needed to "erase" by providing mine explicitly).Adding
with_state
at the end of my MethodRouter builder reset the explicit state to()
which made it a valid service.