Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Bump webhook max size to 5MB #38

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions hook-api/src/handlers/app.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use axum::{routing, Router};
use axum::{extract::DefaultBodyLimit, routing, Router};

use hook_common::pgqueue::PgQueue;

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions hook-api/src/handlers/webhook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -252,7 +252,7 @@ mod tests {

let app = add_routes(Router::new(), pg_queue);

let bytes: Vec<u8> = vec![b'a'; 1_000_000 * 2];
let bytes: Vec<u8> = vec![b'a'; 5_000_000 * 2];
let long_string = String::from_utf8_lossy(&bytes);

let response = app
Expand Down
Loading