include.go 840 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package httpserver
  2. import (
  3. "encoding/json"
  4. "os"
  5. )
  6. type HttpServerConfig struct {
  7. HttpPort int `json:"http_port"`
  8. HttpsPort int `json:"https_port"`
  9. AllowedDomain string `json:"allowed_domain"`
  10. UserAgent string `json:"user_agent"`
  11. UseSsl bool `json:"use_ssl"`
  12. RevProxySite string `json:"rev_proxy_site"`
  13. }
  14. type Cookie struct {
  15. Name string `json:"name"`
  16. Value string `json:"value"`
  17. MaxAge int `json:"max_age"`
  18. Path string `json:"path"`
  19. Domain string `json:"domain"`
  20. Secure bool `json:"secure"`
  21. HttpOnly bool `json:"http_only"`
  22. }
  23. func ReadConfig(loc string) (*HttpServerConfig, error) {
  24. f, err := os.ReadFile(loc)
  25. if err != nil {
  26. return nil, err
  27. }
  28. var cfg HttpServerConfig
  29. err = json.Unmarshal(f, &cfg)
  30. if err != nil {
  31. return nil, err
  32. }
  33. return &cfg, err
  34. }