mirror of
https://github.com/restic/rest-server.git
synced 2026-09-28 06:51:25 -07:00
Don't shadow config struct
This commit is contained in:
+6
-6
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user