-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
I am creating a custom HTTP handler class from a schema specification which has about 100 routes.
Because of reasons, my main dispatcher is basically a match
from a usize to an function invocation:
e.g.
match index {
0 => {
let input = FromRequest::from_request(req).await;
let res = handler_0(input).await;
IntoResponse::into_response(res).await
},
1 => {
let input = FromRequest::from_request(req).await;
let res = handler_0(input).await;
IntoResponse::into_response(res).await
},
N => {
...
}
}
I want to create a Vec<Box<dyn FormatInto<Rust>>
of handlers and then iterate through them and create each match block.
However, I can't, because format_into
takes self
It would be nice if there was an alternative to format_into that didn't consume self. Or maybe there is a better overall approach?
What is the recommended way to create a vector of token streams that I can inject into here?