mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 07:33:21 +00:00
Don't shadow config struct
This commit is contained in:
parent
ff5fbf34e1
commit
c1ace4c9d9
1 changed files with 6 additions and 6 deletions
12
handlers.go
12
handlers.go
|
@ -75,8 +75,8 @@ func CheckConfig(w http.ResponseWriter, r *http.Request) {
|
|||
if config.debug {
|
||||
log.Println("CheckConfig()")
|
||||
}
|
||||
config := filepath.Join(getRepo(r), "config")
|
||||
st, err := os.Stat(config)
|
||||
cfg := filepath.Join(getRepo(r), "config")
|
||||
st, err := os.Stat(cfg)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
|
@ -90,8 +90,8 @@ func GetConfig(w http.ResponseWriter, r *http.Request) {
|
|||
if config.debug {
|
||||
log.Println("GetConfig()")
|
||||
}
|
||||
config := filepath.Join(getRepo(r), "config")
|
||||
bytes, err := ioutil.ReadFile(config)
|
||||
cfg := filepath.Join(getRepo(r), "config")
|
||||
bytes, err := ioutil.ReadFile(cfg)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(http.StatusNotFound), http.StatusNotFound)
|
||||
return
|
||||
|
@ -105,13 +105,13 @@ func SaveConfig(w http.ResponseWriter, r *http.Request) {
|
|||
if config.debug {
|
||||
log.Println("SaveConfig()")
|
||||
}
|
||||
config := filepath.Join(getRepo(r), "config")
|
||||
cfg := filepath.Join(getRepo(r), "config")
|
||||
bytes, err := ioutil.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
|
||||
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)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue