Update GET config API when config file not set

This commit is contained in:
Alexey Khit
2023-01-18 10:00:20 +03:00
parent 6a61b5234e
commit 6e49d51c33
2 changed files with 19 additions and 4 deletions
+6 -1
View File
@@ -9,11 +9,16 @@ import (
)
func configHandler(w http.ResponseWriter, r *http.Request) {
if app.ConfigPath == "" {
http.Error(w, "", http.StatusGone)
return
}
switch r.Method {
case "GET":
data, err := os.ReadFile(app.ConfigPath)
if err != nil {
http.NotFound(w, r)
http.Error(w, "", http.StatusNotFound)
return
}
if _, err = w.Write(data); err != nil {