Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

42 linhas
763B

  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. Static []configStaticHtml
  16. Session struct {
  17. Guest bool
  18. Year int //how many years
  19. Month int //how many years
  20. Day int //how many years
  21. }
  22. }
  23. var configFile = "config.json"
  24. var config = configuration{}
  25. func (m *configuration) readConfig() (e error) {
  26. log.Printf("read Path config from %s", configFile)
  27. body, e := ioutil.ReadFile(configFile)
  28. if e != nil {
  29. log.Fatal("Cannot read config from " + configFile)
  30. return
  31. }
  32. e = json.Unmarshal(body, m)
  33. //TODO: check config before proceed further
  34. return
  35. }