From 96b960bcfcac136309057a419424d8ef2e1b44fe Mon Sep 17 00:00:00 2001 From: Florian Kostenzer Date: Thu, 24 Dec 2020 15:51:12 +0100 Subject: [PATCH] add MAX_BODY_SIZE option --- Sources/SwiftTileserverCache/routes.swift | 8 ++++++-- docker-compose.yml | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftTileserverCache/routes.swift b/Sources/SwiftTileserverCache/routes.swift index 9cb4797..5f57500 100644 --- a/Sources/SwiftTileserverCache/routes.swift +++ b/Sources/SwiftTileserverCache/routes.swift @@ -20,6 +20,10 @@ func routes(_ app: Application) throws { let statsController = StatsController(fileToucher: FileToucher()) + if let maxBodySize = Environment.get("MAX_BODY_SIZE") { + app.routes.defaultMaxBodySize = ByteCount(stringLiteral: maxBodySize) + } + let stylesController = StylesController(tileServerURL: tileServerURL, externalStyles: externalStyles, folder: "TileServer/Styles") app.get("styles", use: stylesController.get) @@ -50,13 +54,13 @@ func routes(_ app: Application) throws { protected.webSocket("api", "datasets", "delete", onUpgrade: datasetController.delete) let fontsController = FontsController(folder: "TileServer/Fonts", tempFolder: "Temp") - protected.on(.POST, "api", "fonts", "add", body: .collect(maxSize: "1mb"), use: fontsController.add) + protected.on(.POST, "api", "fonts", "add", body: .collect(maxSize: "64mb"), use: fontsController.add) protected.delete("api", "fonts", "delete", ":name", use: fontsController.delete) protected.post("api", "styles", "external", "add", use: stylesController.addExternal) protected.delete("api", "styles", "external", ":id", use: stylesController.deleteExternal) - protected.on(.POST, "api", "styles", "local", "add", body: .collect(maxSize: "1mb"), use: stylesController.addLocal) + protected.on(.POST, "api", "styles", "local", "add", body: .collect(maxSize: "64mb"), use: stylesController.addLocal) protected.delete("api", "styles", "local", ":id", use: stylesController.deleteLocal) let templatesController = TemplatesController(folder: "Templates", staticMapController: staticMapController, multiStaticMapController: multiStaticMapController) diff --git a/docker-compose.yml b/docker-compose.yml index e03dbb2..a35d2b0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -33,5 +33,6 @@ services: # ADMIN_PASSWORD: ChangeMe! # PREVIEW_LATIDUDE: 47.377105 # PREVIEW_LONGITUDE: 8.541655 +# MAX_BODY_SIZE: 1mb ports: - 9000:9000