From 497c5afc6d7a479f3f1b0d30ab84f6ccfe166c66 Mon Sep 17 00:00:00 2001 From: gjahn <gregor.jahn@bht-berlin.de> Date: Sat, 25 Nov 2023 00:32:10 +0100 Subject: [PATCH] Add body size limit This is being handled by Fiber, hence not tested. --- configuration/config.go | 3 +++ main.go | 1 + routing/routes_test.go | 1 + 3 files changed, 5 insertions(+) diff --git a/configuration/config.go b/configuration/config.go index 22d9fcf..4943459 100644 --- a/configuration/config.go +++ b/configuration/config.go @@ -8,6 +8,9 @@ import ( ) +const BODY_SIZE_LIMIT = 32 * 1024 * 1024 // 32 MB, in bytes + + type Config struct { Environment string `env:"ENV_NAME" envDefault:"development"` Host string `env:"HOST" envDefault:"127.0.0.1"` diff --git a/main.go b/main.go index cacfd73..f9bbd9f 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ func main() { server := fiber.New( fiber.Config{ AppName: "webservice", DisableStartupMessage: config.Environment != "development", + BodyLimit: configuration.BODY_SIZE_LIMIT, }) var store state.Store diff --git a/routing/routes_test.go b/routing/routes_test.go index c7295c8..bc1cdd8 100644 --- a/routing/routes_test.go +++ b/routing/routes_test.go @@ -28,6 +28,7 @@ func setup() ( *f.App, *configuration.Config, state.Store, *bool ){ server := f.New( f.Config{ AppName: "test", DisableStartupMessage: false, + BodyLimit: configuration.BODY_SIZE_LIMIT, }) store := state.NewEphemeralStore() var isHealthy = true -- GitLab