Browse Source

port to confing

pull/25/head
Alexey Velikiy 3 years ago
parent
commit
4d1297aa8c
  1. 4
      server/src/api.rs
  2. 2
      server/src/config.rs

4
server/src/api.rs

@ -73,9 +73,9 @@ impl API<'_> {
let segments = segments::get_route(self.data_service.clone());
let public = warp::fs::dir("public");
println!("Start server on 8000 port");
println!("Start server on {} port", self.config.port);
// TODO: move it to "server"
let routes = login.or(metrics).or(segments).or(options).or(public).or(not_found);
warp::serve(routes).run(([127, 0, 0, 1], 8000)).await;
warp::serve(routes).run(([127, 0, 0, 1], self.config.port)).await;
}
}

2
server/src/config.rs

@ -1,12 +1,14 @@
pub struct Config {
pub prom_url: String,
pub query: String,
pub port: u16
}
// TODO: use actual config and env variables
impl Config {
pub fn new() -> Config {
Config {
port: 8000,
prom_url: "http://localhost:9090".to_owned(),
query: "rate(go_memstats_alloc_bytes_total[5m])".to_owned(),
}

Loading…
Cancel
Save