From 77a4061cdd7f8134396c28e8f00fb43f855cb243 Mon Sep 17 00:00:00 2001 From: mappu Date: Fri, 19 May 2023 19:04:50 +1200 Subject: [PATCH] contented: move flag parsing, consts into block declaration --- Server.go | 7 +++++-- cmd/contented/main.go | 24 +++++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Server.go b/Server.go index f9bae8c..eaa02d8 100644 --- a/Server.go +++ b/Server.go @@ -20,9 +20,12 @@ var staticAssets embed.FS var SERVER_HEADER string = `contented/0.0.0-dev` -const DEFAULT_MAX_CONCURRENT_THUMBS = 16 +const ( + DEFAULT_MAX_CONCURRENT_THUMBS = 16 -const ALBUM_MIMETYPE = `contented/album` + ALBUM_MIMETYPE = `contented/album` + +) type ServerPublicProperties struct { AppTitle string diff --git a/cmd/contented/main.go b/cmd/contented/main.go index 25c5044..45b9d3f 100644 --- a/cmd/contented/main.go +++ b/cmd/contented/main.go @@ -12,17 +12,19 @@ import ( func main() { cwd, _ := os.Getwd() - listenAddr := flag.String("listen", "127.0.0.1:80", "IP/Port to bind server") - dataDir := flag.String("data", cwd, "Directory for stored content") - dbPath := flag.String("db", "contented.db", "Path for metadata database") - appTitle := flag.String("title", "contented", "Title used in web interface") - maxUploadMb := flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)") - maxUploadSpeed := flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)") - trustXForwardedFor := flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers") - enableHomepage := flag.Bool("enableHomepage", true, "Enable homepage (disable for embedded use only)") - enableUpload := flag.Bool("enableUpload", true, "Enable uploads (disable for read-only mode)") - diskFilesWorldReadable := flag.Bool("diskFilesWorldReadable", false, "Save files as 0644 instead of 0600") - maxConcurrentThumbs := flag.Int("concurrentthumbs", contented.DEFAULT_MAX_CONCURRENT_THUMBS, "Simultaneous thumbnail generation") + var ( + listenAddr = flag.String("listen", "127.0.0.1:80", "IP/Port to bind server") + dataDir = flag.String("data", cwd, "Directory for stored content") + dbPath = flag.String("db", "contented.db", "Path for metadata database") + appTitle = flag.String("title", "contented", "Title used in web interface") + maxUploadMb = flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)") + maxUploadSpeed = flag.Int("speed", 0, "Maximum upload speed in bytes/sec (set zero for unlimited)") + trustXForwardedFor = flag.Bool("trustXForwardedFor", false, "Trust X-Forwarded-For reverse proxy headers") + enableHomepage = flag.Bool("enableHomepage", true, "Enable homepage (disable for embedded use only)") + enableUpload = flag.Bool("enableUpload", true, "Enable uploads (disable for read-only mode)") + diskFilesWorldReadable = flag.Bool("diskFilesWorldReadable", false, "Save files as 0644 instead of 0600") + maxConcurrentThumbs = flag.Int("concurrentthumbs", contented.DEFAULT_MAX_CONCURRENT_THUMBS, "Simultaneous thumbnail generation") + ) flag.Parse()