aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-14 19:07:53 -0700
committerFuwn <[email protected]>2022-04-14 19:07:53 -0700
commitd297e61c1a54728ac546c0a8cd74452af6c2a10d (patch)
tree97ae27d9eede64024749720944b62db7f441df0a /src
parentfeat: descriptions for sitemap (diff)
downloadlocus-d297e61c1a54728ac546c0a8cd74452af6c2a10d.tar.xz
locus-d297e61c1a54728ac546c0a8cd74452af6c2a10d.zip
feat(uptime): more options
Diffstat (limited to 'src')
-rw-r--r--src/main.rs19
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(),
+ }
+ },
+ ))
}),
);