port and host values in config

This commit is contained in:
Dominic Harris 2022-02-28 17:17:18 -05:00
parent d402e68c11
commit d293e59d4d
No known key found for this signature in database
GPG Key ID: 93CCF85F3E2A4F65
3 changed files with 12 additions and 2 deletions

View File

@ -11,6 +11,7 @@ pub struct Config {
#[derive(Serialize, Deserialize, Clone)]
pub struct ServerConfig {
pub backend_host: String,
pub backend_port: u16,
}

View File

@ -136,9 +136,14 @@ async fn main() -> io::Result<()> {
.await
.expect("Failed to connect to database");
let address = format!(
"{}:{}",
config.server.backend_host, config.server.backend_port
);
let state = AppState { config, pool };
println!("🚀 zer0bin is running");
println!("🚀 zer0bin is running on {}", address);
HttpServer::new(move || {
let cors = Cors::default()
@ -153,7 +158,7 @@ async fn main() -> io::Result<()> {
.app_data(Data::new(state.clone()))
.service(web::scope("/p").service(get_paste).service(new_paste))
})
.bind("localhost:8000")?
.bind(address)?
.run()
.await
}

View File

@ -1,4 +1,8 @@
{
"server": {
"backend_host": "localhost",
"backend_port": 8000
},
"pastes": {
"character_limit": 40000,
"days_til_expiration": 7