diff options
author | xengineering <me@xengineering.eu> | 2024-03-25 20:28:51 +0100 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-03-25 20:28:51 +0100 |
commit | 4d2f729a2f65a8d645d83bd857d4b0766c49a887 (patch) | |
tree | 0db828d5479cbe0b73d4fb96a1347dcee9455a9a | |
parent | 9f1fc3ca35845a0fe5501f8a56646d6568e89e48 (diff) | |
download | webiot-4d2f729a2f65a8d645d83bd857d4b0766c49a887.tar webiot-4d2f729a2f65a8d645d83bd857d4b0766c49a887.tar.zst webiot-4d2f729a2f65a8d645d83bd857d4b0766c49a887.zip |
There is no reason anymore to work with a closure here. This commit
makes the code more readable.
-rw-r--r-- | main.go | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -23,7 +23,7 @@ func main() { log.Fatal(err) } - http.HandleFunc("/", index(config.Devices)) + http.HandleFunc("/", index) http.HandleFunc("/api", api) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(static)))) @@ -46,13 +46,11 @@ func parseFlags() string { } // index() returns a HTTP handler for the index page. -func index(devices DevicesConfig) func(http.ResponseWriter, *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - err := templates.Execute(w, devices) - if err != nil { - http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) - return - } +func index(w http.ResponseWriter, r *http.Request) { + err := templates.Execute(w, config.Devices) + if err != nil { + http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) + return } } |