add port on config
This commit is contained in:
parent
49fcf39612
commit
691c766312
2 changed files with 4 additions and 1 deletions
|
@ -3,6 +3,7 @@ use serde::Deserialize;
|
|||
#[derive(Deserialize)]
|
||||
pub struct Config {
|
||||
pub scheme: String,
|
||||
pub port: u16,
|
||||
}
|
||||
|
||||
pub fn get_config(file_path: &str) -> Config {
|
||||
|
@ -18,6 +19,7 @@ pub fn get_config(file_path: &str) -> Config {
|
|||
{
|
||||
Config {
|
||||
scheme: "http".to_string(),
|
||||
port: 8080,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,9 @@ mod index;
|
|||
async fn main() -> std::io::Result<()> {
|
||||
let config = config::get_config("config/config.toml");
|
||||
|
||||
let addr = ("127.0.0.1", 8080);
|
||||
let addr = ("127.0.0.1", config.port);
|
||||
println!("Listening to {}://{}:{}", config.scheme, addr.0, addr.1);
|
||||
|
||||
HttpServer::new(|| App::new().service(index::page))
|
||||
.bind(addr)?
|
||||
.run()
|
||||
|
|
Loading…
Reference in a new issue