32 lines
687 B
Rust
32 lines
687 B
Rust
|
use axum::{
|
||
|
Router,
|
||
|
routing::get
|
||
|
};
|
||
|
use tower_http::trace::TraceLayer;
|
||
|
use tracing::{debug, error, info, warn};
|
||
|
use color_eyre::eyre::Result;
|
||
|
|
||
|
#[tokio::main]
|
||
|
async fn main() -> Result<()> {
|
||
|
color_eyre::install()?;
|
||
|
tracing_subscriber::fmt::init();
|
||
|
info!("Starting server...");
|
||
|
|
||
|
|
||
|
let middleware = tower::ServiceBuilder::new()
|
||
|
.layer(TraceLayer::new_for_http());
|
||
|
|
||
|
let app = Router::new()
|
||
|
.route("/", get(|| async { "Hello world!" }))
|
||
|
.layer(middleware);
|
||
|
|
||
|
|
||
|
info!("Now listening at http://localhost:8180");
|
||
|
|
||
|
axum::Server::bind(&"0.0.0.0:8180".parse().unwrap())
|
||
|
.serve(app.into_make_service())
|
||
|
.await?;
|
||
|
|
||
|
Ok(())
|
||
|
}
|