Skip to content

Commit

Permalink
fix: add x-request-id (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris13524 authored Dec 17, 2023
1 parent 537b8d0 commit 266b4aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ wc = { git = "https://github.com/WalletConnect/utils-rs.git", tag = "v0.7.0", fe
tokio = { version = "1", features = ["full"] }
axum = { version = "0.6", features = ["json", "headers"] }
tower = "0.4"
tower-http = { version = "0.3", features = ["trace", "cors"] }
tower-http = { version = "0.3", features = ["trace", "cors", "request-id", "util"] }
hyper = "0.14"

# Seralisation
Expand Down
4 changes: 4 additions & 0 deletions src/services/public_http_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use {
tower::ServiceBuilder,
tower_http::{
cors::{Any, CorsLayer},
request_id::MakeRequestUuid,
trace::{DefaultMakeSpan, DefaultOnRequest, DefaultOnResponse, TraceLayer},
ServiceBuilderExt,
},
tracing::{info, Level},
wc::geoip::{
Expand All @@ -31,6 +33,7 @@ pub async fn start(
geoip_resolver: Option<Arc<MaxMindResolver>>,
) -> Result<(), hyper::Error> {
let global_middleware = ServiceBuilder::new()
.set_x_request_id(MakeRequestUuid)
.layer(
TraceLayer::new_for_http()
.make_span_with(
Expand All @@ -45,6 +48,7 @@ pub async fn start(
.include_headers(true),
),
)
.propagate_x_request_id()
.layer(
// TODO test
CorsLayer::new()
Expand Down

0 comments on commit 266b4aa

Please sign in to comment.