diff --git a/contrib/lib/src/serve.rs b/contrib/lib/src/serve.rs index a968cd41..a35e3433 100644 --- a/contrib/lib/src/serve.rs +++ b/contrib/lib/src/serve.rs @@ -347,9 +347,9 @@ impl StaticFiles { impl Into> for StaticFiles { fn into(self) -> Vec { + let source = rocket::figment::Source::File(self.root.clone()); let mut route = Route::ranked(self.rank, Method::Get, "/", self); - route.name = Some("StaticFiles"); - // route.name = format!("StaticFiles({})", self.root.fancy_display()); + route.name = Some(format!("StaticFiles: {}/", source).into()); vec![route] } } diff --git a/core/lib/src/router/route.rs b/core/lib/src/router/route.rs index 886c50ce..6a26f15c 100644 --- a/core/lib/src/router/route.rs +++ b/core/lib/src/router/route.rs @@ -1,5 +1,6 @@ use std::fmt::{self, Display}; use std::convert::From; +use std::borrow::Cow; use yansi::Paint; @@ -16,7 +17,7 @@ use crate::form::ValueField; #[derive(Clone)] pub struct Route { /// The name of this route, if one was given. - pub name: Option<&'static str>, + pub name: Option>, /// The method this route matches against. pub method: Method, /// The function that should be called when the route matches. @@ -284,7 +285,7 @@ impl Route { impl fmt::Display for Route { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - if let Some(n) = self.name { + if let Some(ref n) = self.name { write!(f, "{}{}{} ", Paint::cyan("("), Paint::white(n), Paint::cyan(")"))?; } @@ -327,7 +328,7 @@ impl From for Route { // This should never panic since `info.path` is statically checked. let mut route = Route::new(info.method, info.path, info.handler); route.format = info.format; - route.name = Some(info.name); + route.name = Some(info.name.into()); if let Some(rank) = info.rank { route.rank = rank; }