18 lines
585 B
Rust
Raw Normal View History

use std::net::TcpListener;
use email_newsletter_api::{configuration::get_configuration, startup};
2024-03-28 11:42:08 -04:00
#[tokio::main]
2024-05-03 15:43:34 -04:00
async fn main() -> Result<(), std::io::Error> {
let configuration = get_configuration().expect("Failed to read configuration");
let port_number = configuration.application_port;
let listener = TcpListener::bind(format!("127.0.0.1:{}", port_number))
.unwrap_or_else(|_| panic!("Can't bind to port {} at localhost", port_number));
// Move the error up the call stack
// otherwise await for the HttpServer
2024-05-03 15:43:34 -04:00
startup::run(listener)?.await
2024-03-23 19:04:25 -04:00
}