package model import "git.pyer.club/kingecg/gologger" type HttpPath struct { Path string `json:"path"` Root string `json:"root"` Default string `json:"default"` Upstreams []string `json:"upstreams"` Rewrite PathRewrite `json:"pathrewrite"` } type PathRewrite struct { Replace string `json:"replace"` With string `json:"with"` } type HttpServerConfig struct { Name string `json:"name"` ServerName string `json:"server"` Port int `json:"port"` Host string `json:"host"` Paths []HttpPath Username string `json:"username"` Password string `json:"password"` CertFile string `json:"certfile"` KeyFile string `json:"keyfile"` } type GoHttpdConfig struct { Logging gologger.LoggersConfig `json:"logging"` Admin *HttpServerConfig `json:"admin"` Servers []*HttpServerConfig `json:"servers"` } var DefaultAdminConfig HttpServerConfig = HttpServerConfig{ ServerName: "admin", Port: 8080, } var Config GoHttpdConfig = GoHttpdConfig{} func GetConfig() *GoHttpdConfig { return &Config } func SetServerConfig(c *HttpServerConfig) { for i, s := range Config.Servers { if s.Name == c.Name { Config.Servers[i] = c return } } Config.Servers = append(Config.Servers, c) } func GetServerConfig(name string) *HttpServerConfig { for _, s := range Config.Servers { if s.Name == name { return s } } return nil }