Don't shadow config struct

This commit is contained in:
Zlatko Čalušić 2017-01-16 23:00:46 +01:00
parent ff5fbf34e1
commit c1ace4c9d9

View file

@ -75,8 +75,8 @@ func CheckConfig(w http.ResponseWriter, r *http.Request) {
if config.debug { if config.debug {
log.Println("CheckConfig()") log.Println("CheckConfig()")
} }
config := filepath.Join(getRepo(r), "config") cfg := filepath.Join(getRepo(r), "config")
st, err := os.Stat(config) st, err := os.Stat(cfg)
if err != nil { if err != nil {
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return return
@ -90,8 +90,8 @@ func GetConfig(w http.ResponseWriter, r *http.Request) {
if config.debug { if config.debug {
log.Println("GetConfig()") log.Println("GetConfig()")
} }
config := filepath.Join(getRepo(r), "config") cfg := filepath.Join(getRepo(r), "config")
bytes, err := ioutil.ReadFile(config) bytes, err := ioutil.ReadFile(cfg)
if err != nil { if err != nil {
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound) http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
return return
@ -105,13 +105,13 @@ func SaveConfig(w http.ResponseWriter, r *http.Request) {
if config.debug { if config.debug {
log.Println("SaveConfig()") log.Println("SaveConfig()")
} }
config := filepath.Join(getRepo(r), "config") cfg := filepath.Join(getRepo(r), "config")
bytes, err := ioutil.ReadAll(r.Body) bytes, err := ioutil.ReadAll(r.Body)
if err != nil { if err != nil {
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
return return
} }
if err := ioutil.WriteFile(config, bytes, 0600); err != nil { if err := ioutil.WriteFile(cfg, bytes, 0600); err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return return
} }