canaryBot/config.go
config.goRaw
1package main
2
3import (
4 "encoding/json"
5 "io/ioutil"
6)
7
8//MatrixConfig stores the matrix data config
9type MatrixConfig struct {
10 RoomId string `json:"room_id"`
11 User string `json:"user"`
12 Password string `json:"password"`
13 Server string `json:"server"`
14}
15type Service struct {
16 Name string `json:"name"`
17 Url string `json:"url"`
18 StatusCode int `json:"statusCode"`
19 Counter int
20}
21type Config struct {
22 Matrix MatrixConfig `json:"matrix"`
23 Services []Service `json:"services"`
24 SleepTime int `json:"sleepTime"`
25 Retry int `json:"retry"`
26}
27
28var config Config
29
30func readConfig() {
31 file, e := ioutil.ReadFile("config.json")
32 if e != nil {
33 panic(e)
34 }
35 content := string(file)
36 json.Unmarshal([]byte(content), &config)
37}