-
Where please is it documented how that should be implemented with axum? From a buildable example I made: (https://github.com/kellytk/x-variables/blob/main/src/main.rs#L11)
If that's impossible, then is https://docs.rs/axum/0.2.5/axum/#sharing-state-with-handlers the only method available? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
In axum handlers accept zero or several extractors. Extractor is a type that implement FromRequest trait (more info).
|
Beta Was this translation helpful? Give feedback.
-
From the example it kind of looks like you want something like this: let app = Router::new().route("/", get(move |body: Json<Something>| {
let var = var.clone();
endpoint::handler(body, var)
})); but the |
Beta Was this translation helpful? Give feedback.
From the example it kind of looks like you want something like this:
but the
AddExtension
middleware would probably easier to work with.