Skip to content

Dynamic routes #2194

Answered by davidpdrsn
shrynx asked this question in Q&A
Aug 23, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Does using with_state on get instead work?

let mut img_router = Router::new();

for img_route_config in config.img_route_configs.iter() {
    img_router = img_router
        .route(
            &format!("{}", img_route_config.path),
            get(handle_img).with_state(BucketConfig { bucket_name: &img_route_config.bucket })
        );
}

That uses MethodRouter::with_state

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@shrynx
Comment options

Answer selected by shrynx

This comment has been hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants