You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
775 B

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