Skip to content

Commit

Permalink
Set local body limit to 100MB
Browse files Browse the repository at this point in the history
  • Loading branch information
ostenbom committed Jun 7, 2024
1 parent 4ed1002 commit 2396d2f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions linkup-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,3 @@ base64 = "0.22.1"

[dev-dependencies]
mockall = "0.12.1"

# Optimise the cli for size
[profile.release]
opt-level = "s"
1 change: 1 addition & 0 deletions local-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ rustls-native-certs = "0.7.0"
thiserror = "1"
tokio = { version="1", features=["macros", "signal"] }
tower-http = {version="0.5.2", features=["trace"]}
tower = "0.4.13"

13 changes: 9 additions & 4 deletions local-server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use axum::{
body::Body,
extract::{Json, Request},
extract::{DefaultBodyLimit, Json, Request},
http::StatusCode,
response::{IntoResponse, Response},
routing::{any, get, post},
Expand All @@ -18,6 +18,7 @@ use linkup::{
Session, SessionAllocator, TargetService, UpdateSessionRequest,
};
use tokio::signal;
use tower::ServiceBuilder;
use tower_http::trace::{DefaultOnRequest, DefaultOnResponse, TraceLayer};

type HttpsClient = Client<HttpsConnector<HttpConnector>, Body>;
Expand Down Expand Up @@ -60,9 +61,13 @@ pub fn linkup_router() -> Router {
.layer(Extension(config_store))
.layer(Extension(client))
.layer(
TraceLayer::new_for_http()
.on_request(DefaultOnRequest::new()) // Log all incoming requests at INFO level
.on_response(DefaultOnResponse::new()), // Log all responses at INFO level
ServiceBuilder::new()
.layer(DefaultBodyLimit::max(1024 * 1024 * 100)) // Set max body size to 100MB
.layer(
TraceLayer::new_for_http()
.on_request(DefaultOnRequest::new()) // Log all incoming requests at INFO level
.on_response(DefaultOnResponse::new()), // Log all responses at INFO level
),
)
}

Expand Down

0 comments on commit 2396d2f

Please sign in to comment.