From 00705c79a109fb2e63c55e6ec6c590c18658af26 Mon Sep 17 00:00:00 2001 From: Brett Hoerner Date: Fri, 3 May 2024 10:34:13 -0600 Subject: [PATCH] Bump webhook max size to 5MB --- hook-api/src/handlers/app.rs | 9 +++++++-- hook-api/src/handlers/webhook.rs | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hook-api/src/handlers/app.rs b/hook-api/src/handlers/app.rs index f8d4b24..fa2bcbc 100644 --- a/hook-api/src/handlers/app.rs +++ b/hook-api/src/handlers/app.rs @@ -1,4 +1,4 @@ -use axum::{routing, Router}; +use axum::{extract::DefaultBodyLimit, routing, Router}; use hook_common::pgqueue::PgQueue; @@ -9,7 +9,12 @@ pub fn add_routes(router: Router, pg_pool: PgQueue) -> Router { .route("/", routing::get(index)) .route("/_readiness", routing::get(index)) .route("/_liveness", routing::get(index)) // No async loop for now, just check axum health - .route("/webhook", routing::post(webhook::post).with_state(pg_pool)) + .route( + "/webhook", + routing::post(webhook::post) + .with_state(pg_pool) + .layer(DefaultBodyLimit::disable()), + ) } pub async fn index() -> &'static str { diff --git a/hook-api/src/handlers/webhook.rs b/hook-api/src/handlers/webhook.rs index e50b8b0..47f21a6 100644 --- a/hook-api/src/handlers/webhook.rs +++ b/hook-api/src/handlers/webhook.rs @@ -9,7 +9,7 @@ use hook_common::pgqueue::{NewJob, PgQueue}; use serde::Serialize; use tracing::{debug, error}; -const MAX_BODY_SIZE: usize = 1_000_000; +pub const MAX_BODY_SIZE: usize = 5_000_000; #[derive(Serialize, Deserialize)] pub struct WebhookPostResponse { @@ -252,7 +252,7 @@ mod tests { let app = add_routes(Router::new(), pg_queue); - let bytes: Vec = vec![b'a'; 1_000_000 * 2]; + let bytes: Vec = vec![b'a'; 5_000_000 * 2]; let long_string = String::from_utf8_lossy(&bytes); let response = app