Skip to content
Snippets Groups Projects
Commit 3eca9706 authored by codecraft's avatar codecraft :crocodile:
Browse files

Adding route and mountpoint listing

parent 19c473ea
No related branches found
No related tags found
1 merge request!1Initial feature merge
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment