No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

49 líneas
854B

  1. package main
  2. import (
  3. "encoding/json"
  4. "io/ioutil"
  5. "log"
  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. DSN string
  16. TlsCert string
  17. TlsKey string
  18. Static []configStaticHtml
  19. Debug bool
  20. TempDir string
  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. if config.Debug {
  39. log.Println(config)
  40. }
  41. return
  42. }