mirror of
https://github.com/kristoferssolo/axum-template.git
synced 2025-10-21 17:20:35 +00:00
22 lines
748 B
Rust
22 lines
748 B
Rust
use {{crate_name}}::{
|
|
config::get_config,
|
|
routes::route,
|
|
telemetry::{get_subscriber, init_subscriber},
|
|
};
|
|
use sqlx::postgres::PgPoolOptions;
|
|
use tokio::net::TcpListener;
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), std::io::Error> {
|
|
let subscriber = get_subscriber("{{project-name}}", "info", std::io::stdout);
|
|
init_subscriber(subscriber);
|
|
let config = get_config().expect("Failed to read configuation.");
|
|
let pool = PgPoolOptions::new().connect_lazy_with(config.database.with_db());
|
|
let addr = format!("{}:{}", config.application.host, config.application.port);
|
|
let listener = TcpListener::bind(addr)
|
|
.await
|
|
.expect("Failed to bind port 8000.");
|
|
|
|
axum::serve(listener, route(pool)).await
|
|
}
|