Skip to content

Commit

Permalink
add MAX_BODY_SIZE option
Browse files Browse the repository at this point in the history
  • Loading branch information
123FLO321 committed Dec 24, 2020
1 parent 5d6335d commit 96b960b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Sources/SwiftTileserverCache/routes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ services:
# ADMIN_PASSWORD: ChangeMe!
# PREVIEW_LATIDUDE: 47.377105
# PREVIEW_LONGITUDE: 8.541655
# MAX_BODY_SIZE: 1mb
ports:
- 9000:9000

0 comments on commit 96b960b

Please sign in to comment.