diff options
| -rw-r--r-- | src/main.rs | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 2c5c7f5..582b032 100644 --- a/src/main.rs +++ b/src/main.rs @@ -147,12 +147,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { track_mount( &mut router, "/uptime", - "The uptime of Locus, in seconds (A.K.A., The Locus Epoch)", + "The uptime of Locus (A.K.A., The Locus Epoch). (\\?[s|ms|mu|ns]?)?", Box::new(move |context| { - success!( - &format!("# UPTIME\n\n{} seconds", uptime.elapsed().as_secs()), - context - ) + Response::Success(context.url.query().map_or_else( + || uptime.elapsed().as_nanos().to_string(), + |query| { + match query { + "secs" | "seconds" | "s" => uptime.elapsed().as_secs().to_string(), + "milli" | "milliseconds" | "ms" => + uptime.elapsed().as_millis().to_string(), + "micro" | "microseconds" | "mu" => + uptime.elapsed().as_micros().to_string(), + _ => uptime.elapsed().as_nanos().to_string(), + } + }, + )) }), ); |