feat(server): tracing and http2

main
Jef Roosens 2023-07-15 20:07:19 +02:00
parent 5a5ab7ad52
commit b6179147f3
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 8 additions and 3 deletions

View File

@ -6,12 +6,13 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
axum = "0.6.18"
axum = { version = "0.6.18", features = ["http2"] }
futures = "0.3.28"
libarchive = { path = "../libarchive" }
sha256 = "1.1.4"
tokio = { version = "1.29.1", features = ["full"] }
tokio-util = { version = "0.7.8", features = ["io"] }
tower = { version = "0.4.13", features = ["make"] }
tower-http = { version = "0.4.1", features = ["fs"] }
tower-http = { version = "0.4.1", features = ["fs", "trace"] }
tracing-subscriber = "0.3.17"
uuid = { version = "1.4.0", features = ["v4"] }

View File

@ -8,6 +8,7 @@ use axum::Router;
use repo::RepoGroupManager;
use std::path::PathBuf;
use std::sync::{Arc, RwLock};
use tower_http::trace::TraceLayer;
#[derive(Clone)]
pub struct Config {
@ -42,10 +43,13 @@ async fn main() {
repo_manager: Arc::new(RwLock::new(repo_manager)),
};
tracing_subscriber::fmt::init();
// build our application with a single route
let app = Router::new()
.merge(repo::router(&global))
.with_state(global);
.with_state(global)
.layer(TraceLayer::new_for_http());
// run it with hyper on localhost:3000
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())