fix order of iter chain
This commit is contained in:
parent
d5232b1145
commit
f381cc60b4
2 changed files with 7 additions and 6 deletions
|
|
@ -61,17 +61,18 @@ pub struct Config {
|
|||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
#[serde(crate = "rocket::serde")]
|
||||
pub struct Route {
|
||||
from: Multiable<String>,
|
||||
to: String,
|
||||
pub from: Multiable<String>,
|
||||
pub to: String,
|
||||
#[serde(default)]
|
||||
using: MatcherType,
|
||||
pub using: MatcherType,
|
||||
#[serde(default)]
|
||||
hidden: bool
|
||||
pub hidden: bool
|
||||
}
|
||||
|
||||
/// Something that can either be a single item or multiple items.
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
|
||||
#[serde(crate = "rocket::serde", untagged)]
|
||||
enum Multiable<T> {
|
||||
pub enum Multiable<T> {
|
||||
Single(T),
|
||||
Multi(Vec<T>)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use rocket_dyn_templates::{Template, tera::Tera, context};
|
|||
async fn list_paths(cm: &State<ConfigManager>) -> Result<String, NoContent> {
|
||||
let config = cm.get().await;
|
||||
if config.hide_routes { return Err(NoContent) }
|
||||
let all_routes = config.routes.iter().flat_map(|r: &Route| r.src()).filter(|r| !r.hidden).collect::<Vec<String>>();
|
||||
let all_routes = config.routes.iter().filter(|r| !r.hidden).flat_map(|r: &Route| r.src()).collect::<Vec<String>>();
|
||||
if all_routes.is_empty() { Err(NoContent) } else {
|
||||
Ok(all_routes.into_iter().map(|a| format!("/{}", a)).collect::<Vec<String>>().join("\n"))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue