12345678910111213141516171819202122232425262728293031323334353637383940 |
- package httpserver
- import (
- "encoding/json"
- "os"
- )
- type HttpServerConfig struct {
- HttpPort int `json:"http_port"`
- HttpsPort int `json:"https_port"`
- AllowedDomain string `json:"allowed_domain"`
- UserAgent string `json:"user_agent"`
- UseSsl bool `json:"use_ssl"`
- }
- type Cookie struct {
- Name string `json:"name"`
- Value string `json:"value"`
- MaxAge int `json:"max_age"`
- Path string `json:"path"`
- Domain string `json:"domain"`
- Secure bool `json:"secure"`
- HttpOnly bool `json:"http_only"`
- }
- func ReadConfig(loc string) (*HttpServerConfig, error) {
- f, err := os.ReadFile(loc)
- if err != nil {
- return nil, err
- }
- var cfg HttpServerConfig
- err = json.Unmarshal(f, &cfg)
- if err != nil {
- return nil, err
- }
- return &cfg, err
- }
|