From 3eca9706cc21fb46fccfbaeaacef9bf83cf4da5f Mon Sep 17 00:00:00 2001 From: Darius Auding <Darius.auding@gmx.de> Date: Thu, 18 May 2023 18:53:05 +0200 Subject: [PATCH] Adding route and mountpoint listing --- core/http/src/setup.rs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/core/http/src/setup.rs b/core/http/src/setup.rs index e2ba232..4bacada 100644 --- a/core/http/src/setup.rs +++ b/core/http/src/setup.rs @@ -27,6 +27,24 @@ pub struct Config { impl<'a> Config { pub fn mount(mut self, mountpoint: Uri<'static>, routes: Vec<Route<'static>>) -> Config { + let mut mount_message = format!(" >> \x1b[35m{}\x1b[0m\n", mountpoint); + for (index, route) in routes.iter().enumerate() { + let indent_sign; + match index { + i if i == routes.len() - 1 => indent_sign = "└─", + _ => indent_sign = "├─", + }; + + mount_message += &format!( + " \x1b[35m{indent_sign}\x1b[0m \x1b[36m(\x1b[0m{}\x1b[36m)\x1b[0m \x1b[32m{}\x1b[0m \x1b[34;4m{}\x1b[24m{}\x1b[0m\n", + route.name.unwrap_or(""), + route.method, + mountpoint, + route.uri + ) + } + + println!("{mount_message}"); let mut temp_mountpoints = None; std::mem::swap(&mut self.mountpoints, &mut temp_mountpoints); @@ -78,9 +96,7 @@ pub fn build(ip: &str) -> Config { >> \x1b[34mIp\x1b[0m: {ip} >> \x1b[34mPort\x1b[0m: {port} >> \x1b[34mWorkers\x1b[0m: {workers} -\n -Server has launched from {ip}:{port}. -" +\x1b[35m🛪 Mountpoints\x1b[0m" ); Config { mountpoints: None, -- GitLab