From 4eacd5f54074c6cd73eaef4178c56843ce742445 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 12 Apr 2023 18:50:34 +0200 Subject: Switch to unnested config This is now just not needed. --- config.go | 4 ---- config/debug.json | 10 ++++------ config/default.json | 10 ++++------ handler.go | 2 +- server.go | 2 +- templates.go | 2 +- 6 files changed, 11 insertions(+), 19 deletions(-) diff --git a/config.go b/config.go index 46685d2..4866b23 100644 --- a/config.go +++ b/config.go @@ -11,10 +11,6 @@ import ( type RuntimeConfig struct { Path string - Http HttpConfig `json:"http"` -} - -type HttpConfig struct { Host string `json:"bind_host"` Port string `json:"bind_port"` Static string `json:"static"` diff --git a/config/debug.json b/config/debug.json index 8333e1e..47e80ea 100644 --- a/config/debug.json +++ b/config/debug.json @@ -1,8 +1,6 @@ { - "http":{ - "bind_host":"127.0.0.1", - "bind_port":"8080", - "static":"./data/static", - "templates":"./data/templates" - } + "bind_host":"127.0.0.1", + "bind_port":"8080", + "static":"./data/static", + "templates":"./data/templates" } diff --git a/config/default.json b/config/default.json index 0fbcf09..02220d3 100644 --- a/config/default.json +++ b/config/default.json @@ -1,8 +1,6 @@ { - "http":{ - "bind_host":"127.0.0.1", - "bind_port":"8080", - "static":"/usr/share/ceres/static", - "templates":"/usr/share/ceres/templates" - } + "bind_host":"127.0.0.1", + "bind_port":"8080", + "static":"/usr/share/ceres/static", + "templates":"/usr/share/ceres/templates" } diff --git a/handler.go b/handler.go index a480ce3..e197be7 100644 --- a/handler.go +++ b/handler.go @@ -209,6 +209,6 @@ func addRecipesGet(w http.ResponseWriter, r *http.Request) { func staticGet(w http.ResponseWriter, r *http.Request, filename string) { - path := filepath.Join(config.Http.Static, filename) + path := filepath.Join(config.Static, filename) http.ServeFile(w, r, path) } diff --git a/server.go b/server.go index 4a685f2..891a7b9 100644 --- a/server.go +++ b/server.go @@ -19,7 +19,7 @@ func setupRoutes() { func runServer() { setupRoutes() - address := config.Http.Host + ":" + config.Http.Port + address := config.Host + ":" + config.Port log.Println("Serving content at 'http://" + address + "'.") log.Fatal(http.ListenAndServe(address, nil)) } diff --git a/templates.go b/templates.go index 6b4fe51..2c3e79c 100644 --- a/templates.go +++ b/templates.go @@ -8,7 +8,7 @@ import ( ) func setupTemplates() *template.Template { - t, err := template.ParseGlob(config.Http.Templates + "/*.html") + t, err := template.ParseGlob(config.Templates + "/*.html") if err != nil { panic(err) } -- cgit v1.2.3-70-g09d2