michalvankodev-site/axum_server/src/main.rs

31 lines
1012 B
Rust
Raw Normal View History

2024-01-09 20:54:36 +01:00
use axum;
2024-01-09 19:54:25 +01:00
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
2024-01-11 20:43:47 +01:00
mod pages;
2024-01-09 20:54:36 +01:00
mod post_parser;
mod router;
2024-01-11 20:43:47 +01:00
// mod template;
2024-01-09 20:54:36 +01:00
2024-01-09 19:54:25 +01:00
#[tokio::main]
async fn main() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
// axum logs rejections from built-in extractors with the `axum::rejection`
// target, at `TRACE` level. `axum::rejection=trace` enables showing those events
"axum_server=debug,tower_http=debug,axum::rejection=trace".into()
}),
)
.with(tracing_subscriber::fmt::layer())
.init();
// build our application with a single route
2024-01-09 20:54:36 +01:00
let app = router::get_router();
2024-01-09 19:54:25 +01:00
// run our app with hyper, listening globally on port 3080
let listener = tokio::net::TcpListener::bind("0.0.0.0:3080").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
// TODO Port from env variable
// TODO templating system