fix order of iter chain
Some checks failed
/ build (push) Successful in 4m20s
/ trivy (push) Failing after 17s

This commit is contained in:
Dustin Thomas 2026-01-30 12:59:46 -06:00
parent d5232b1145
commit f381cc60b4
Signed by: cptlobster
GPG key ID: 33D607425C830B4C
2 changed files with 7 additions and 6 deletions

View file

@ -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>)
}

View file

@ -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"))
}