Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

45 lignes
809B

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