Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

56 Zeilen
1.0KB

  1. package main
  2. import (
  3. "encoding/json"
  4. log "github.com/sirupsen/logrus"
  5. "io/ioutil"
  6. "strings"
  7. )
  8. type configStaticHtml struct {
  9. Dir string
  10. StaticUrl string
  11. StripPrefix string
  12. }
  13. type configuration struct {
  14. Host string
  15. Port string
  16. DSN string
  17. TlsCert string
  18. TlsKey string
  19. Static []configStaticHtml
  20. Debug bool
  21. Session struct { //TODO: figure what is this intended for
  22. Guest bool
  23. Year int //how many years
  24. Month int //how many years
  25. Day int //how many years
  26. }
  27. }
  28. var configFile = "config.json"
  29. var config = configuration{}
  30. func (m *configuration) readConfig() (e error) {
  31. log.Printf("read Path config from %s", configFile)
  32. body, e := ioutil.ReadFile(configFile)
  33. if e != nil {
  34. log.Fatal("Cannot read config from " + configFile)
  35. return
  36. }
  37. e = json.Unmarshal(body, m)
  38. //TODO: check config before proceed further
  39. return
  40. }
  41. func (m *configuration) getAvatarPath() (ret string) {
  42. for _, v := range m.Static {
  43. if strings.ToLower(v.Dir) == "avatar" {
  44. return v.Dir //found it
  45. }
  46. }
  47. return ""
  48. }