michalvankodev-site/axum_server/src/main.rs

35 lines
1.1 KiB
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-18 22:33:36 +01:00
mod components;
2024-01-30 22:19:36 +01:00
mod feed;
2024-01-11 20:43:47 +01:00
mod pages;
2024-01-18 22:33:36 +01:00
mod post_list;
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 port = std::option_env!("PORT").unwrap_or("3080");
let addr = format!("0.0.0.0:{}", port);
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
2024-01-09 19:54:25 +01:00
axum::serve(listener, app).await.unwrap();
}
2024-01-18 20:31:25 +01:00
// TODO displaying Image from netlify CDN