2015-04-30 00:18:08 -04:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"io/ioutil"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2015-05-02 21:56:41 -04:00
|
|
|
Dev bool `json:"dev"`
|
2015-04-30 00:18:08 -04:00
|
|
|
Domains []string `json:"domains"`
|
|
|
|
Interval int `json:"interval"`
|
|
|
|
Token string `json:"token"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func LoadConfigs(path string) ([]Config, error) {
|
|
|
|
var configs struct {
|
|
|
|
Configs []Config
|
|
|
|
}
|
|
|
|
|
|
|
|
file, err := ioutil.ReadFile(path)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = json.Unmarshal(file, &configs)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return configs.Configs, nil
|
|
|
|
}
|