-
Normally the configuration information for web is loaded from the configuration file, like the example below. But I'm getting a lot of ownership errors, and as a rust newbie, I don't know how to fix it. I would like to know how this customization of services and routes based on configuration files should be implemented. thanks.
|
Beta Was this translation helpful? Give feedback.
Answered by
sunli829
Jan 22, 2022
Replies: 1 comment 2 replies
-
You should do it like this: let mut route = Route::new();
if let Some(ui_path) = &config.ui_path {
route = route.nest(format!("/{}", ui_path), &serv.rapidoc());
}
if let Some(spec_path) = &config.spec_path {
route = route.at(format!("/{}", spec_path), poem::endpoint::make_sync(move |_| serv.spec().clone()));
} |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
gudaoxuri
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should do it like this: