Skip to content

Commit

Permalink
add config api support
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Jun 21, 2020
1 parent 0dd2dc9 commit d401cc1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ type Config struct {
Configs []RelayConfig
}

type HttpConfigJsonResp struct {
Configs []RelayConfig `json:"configs"`
}

func NewConfig(path string) *Config {
return &Config{PATH: path, Configs: []RelayConfig{}}
}
Expand Down Expand Up @@ -52,7 +56,9 @@ func (c *Config) readFromHttp() error {
return err
}
defer r.Body.Close()
json.NewDecoder(r.Body).Decode(&c.Configs)
log.Println("[INFO] load config from http:", c.PATH)
resp := HttpConfigJsonResp{}
json.NewDecoder(r.Body).Decode(&resp)
c.Configs = resp.Configs
log.Println("[INFO] load config from http:", c.PATH, c.Configs)
return nil
}

0 comments on commit d401cc1

Please sign in to comment.