partial tower/tower-http sentry and gzip/brotli compression
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
3103ad2205
commit
b437e47d8c
3 changed files with 53 additions and 6 deletions
41
Cargo.lock
generated
41
Cargo.lock
generated
|
@ -38,6 +38,21 @@ dependencies = [
|
|||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloc-no-stdlib"
|
||||
version = "2.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3"
|
||||
|
||||
[[package]]
|
||||
name = "alloc-stdlib"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "allocator-api2"
|
||||
version = "0.2.16"
|
||||
|
@ -86,6 +101,8 @@ version = "0.4.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a116f46a969224200a0a97f29cfd4c50e7534e4b4826bd23ea2c3c533039c82c"
|
||||
dependencies = [
|
||||
"brotli",
|
||||
"flate2",
|
||||
"futures-core",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
|
@ -289,6 +306,27 @@ dependencies = [
|
|||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brotli"
|
||||
version = "3.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "516074a47ef4bce09577a3b379392300159ce5b1ba2e501ff1c819950066100f"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
"brotli-decompressor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "brotli-decompressor"
|
||||
version = "2.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e2e4afe60d7dd600fdd3de8d0f08c2b7ec039712e3b6137ff98b7004e82de4f"
|
||||
dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
"alloc-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.15.4"
|
||||
|
@ -462,6 +500,7 @@ dependencies = [
|
|||
"rust-rocksdb",
|
||||
"sd-notify",
|
||||
"sentry",
|
||||
"sentry-tower",
|
||||
"sentry-tracing",
|
||||
"serde",
|
||||
"serde_html_form",
|
||||
|
@ -2137,6 +2176,7 @@ version = "0.11.27"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
|
||||
dependencies = [
|
||||
"async-compression",
|
||||
"base64 0.21.7",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
|
@ -2166,6 +2206,7 @@ dependencies = [
|
|||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tokio-socks",
|
||||
"tokio-util",
|
||||
"tower-service",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
|
|
11
Cargo.toml
11
Cargo.toml
|
@ -135,12 +135,10 @@ features = ["jpeg", "png", "gif", "webp"]
|
|||
version = "0.4.21"
|
||||
default-features = false
|
||||
features = ["max_level_trace", "release_max_level_info"]
|
||||
|
||||
[dependencies.tracing]
|
||||
version = "0.1.40"
|
||||
default-features = false
|
||||
features = ["max_level_trace", "release_max_level_info"]
|
||||
|
||||
[dependencies.tracing-subscriber]
|
||||
version = "0.3.18"
|
||||
features = ["env-filter"]
|
||||
|
@ -178,6 +176,9 @@ features = ["backtrace", "contexts", "debug-images", "panic", "rustls", "tower",
|
|||
[dependencies.sentry-tracing]
|
||||
version = "0.32.2"
|
||||
optional = true
|
||||
[dependencies.sentry-tower]
|
||||
version = "0.32.2"
|
||||
optional = true
|
||||
|
||||
# optional jemalloc usage
|
||||
[dependencies.tikv-jemallocator]
|
||||
|
@ -300,11 +301,11 @@ rocksdb = ["rust-rocksdb", "num_cpus"]
|
|||
jemalloc = ["tikv-jemalloc-ctl", "tikv-jemallocator"]
|
||||
sqlite = ["rusqlite", "parking_lot", "thread_local", "num_cpus"]
|
||||
systemd = ["sd-notify"]
|
||||
sentry_telemetry = ["sentry", "sentry-tracing"]
|
||||
sentry_telemetry = ["sentry", "sentry-tracing", "sentry-tower"]
|
||||
|
||||
#gzip_compression = ["tower-http/compression-gzip"]
|
||||
gzip_compression = ["tower-http/compression-gzip", "reqwest/gzip"]
|
||||
zstd_compression = ["tower-http/compression-zstd"]
|
||||
#brotli_compression = ["tower-http/compression-br"]
|
||||
brotli_compression = ["tower-http/compression-br", "reqwest/brotli"]
|
||||
#all_compression = ["tower-http/compression-full"] # all compression algos
|
||||
|
||||
sha256_media = ["sha2"]
|
||||
|
|
|
@ -243,7 +243,12 @@ async fn run_server() -> io::Result<()> {
|
|||
let x_requested_with = HeaderName::from_static("x-requested-with");
|
||||
let x_forwarded_for = HeaderName::from_static("x-forwarded-for");
|
||||
|
||||
let middlewares = ServiceBuilder::new()
|
||||
let base_middlewares = ServiceBuilder::new();
|
||||
|
||||
#[cfg(feature = "sentry_telemetry")]
|
||||
let base_middlewares = base_middlewares.layer(sentry_tower::NewSentryLayer::<http::Request<_>>::new_from_top());
|
||||
|
||||
let middlewares = base_middlewares
|
||||
.sensitive_headers([header::AUTHORIZATION])
|
||||
.sensitive_request_headers([x_forwarded_for].into())
|
||||
.layer(axum::middleware::from_fn(spawn_task))
|
||||
|
|
Loading…
Add table
Reference in a new issue