diff --git a/lib/routes/routes.go b/lib/routes/routes.go index c7ad6ec7..88903786 100644 --- a/lib/routes/routes.go +++ b/lib/routes/routes.go @@ -268,11 +268,21 @@ func NewRouter() *mux.Router { r.Use(midware.ArrowIPAddr) for _, router := range routers { - r.Methods(router.Method). - Path(router.Pattern). - Handler(router.Handler) + // r.Methods(router.Method). + // Path(router.Pattern). + // Handler(router.Handler) + // if router.Middleware != nil { + // r.Use(router.Middleware) + // } + // if router.Middleware != nil { + // r.HandleFunc(router.Pattern, router.Handler).Methods(router.Method).Subrouter().Use(router.Middleware) + // } else { + // r.HandleFunc(router.Pattern, router.Handler).Methods(router.Method) + // } + rt := r.Methods(router.Method).Subrouter() + rt.HandleFunc(router.Pattern, router.Handler) if router.Middleware != nil { - r.Use(router.Middleware) + rt.Use(router.Middleware) } } diff --git a/restagent/config/config.go b/restagent/config/config.go index 53320c3c..f4ba1cfd 100644 --- a/restagent/config/config.go +++ b/restagent/config/config.go @@ -35,7 +35,7 @@ type YamlConfig struct { IPv4 string `yaml:"ipv4"` IPv6 string `yaml:"ipv6"` Port uint16 `yaml:"port"` - Schema string `yaml:"schema"` + Scheme string `yaml:"scheme"` CaFile string `yaml:"caFile"` CertFile string `yaml:"certFile"` KeyFile string `yaml:"keyFile"` @@ -46,7 +46,7 @@ type YamlConfig struct { RootDir string `yaml:"rootDir"` Listen []struct { Addr string `yaml:"addr"` - Schema string `yaml:"schema"` + Scheme string `yaml:"scheme"` CaFile string `yaml:"caFile"` CertFile string `yaml:"certFile"` KeyFile string `yaml:"keyFile"` diff --git a/restagent/etc/restconf.yaml b/restagent/etc/restconf.yaml index 5a2a5737..0f5e4831 100644 --- a/restagent/etc/restconf.yaml +++ b/restagent/etc/restconf.yaml @@ -17,7 +17,7 @@ rest: - ipv4: 0.0.0.0 ipv6: port: 4443 - schema: https + scheme: https caFile: ./etc/certs/rootca.crt certFile: ./etc/certs/tsa-omc.crt keyFile: ./etc/certs/tsa-omc_pri.key @@ -29,7 +29,7 @@ webServer: - addr: :8080 schema: http - addr: :8443 - schema: https + scheme: https caFile: ./etc/certs/rootca.crt certFile: ./etc/certs/tsa-omc.crt keyFile: ./etc/certs/tsa-omc_pri.key diff --git a/restagent/restagent.go b/restagent/restagent.go index c6fff4f5..16925e0f 100644 --- a/restagent/restagent.go +++ b/restagent/restagent.go @@ -173,7 +173,7 @@ func main() { // ipv4 goroutines if rest.IPv4 != "" { listen := rest.IPv4 + ":" + strconv.Itoa(int(rest.Port)) - if strings.ToLower(rest.Schema) == "https" { + if strings.ToLower(rest.Scheme) == "https" { go HttpListenTLS(listen, rest.CertFile, rest.KeyFile, router) } else { go HttpListen(listen, router) @@ -183,7 +183,7 @@ func main() { // ipv6 goroutines if rest.IPv6 != "" { listenv6 := "[" + rest.IPv6 + "]" + ":" + strconv.Itoa(int(rest.Port)) - if strings.ToLower(rest.Schema) == "https" { + if strings.ToLower(rest.Scheme) == "https" { go HttpListenTLS(listenv6, rest.CertFile, rest.KeyFile, router) } else { go HttpListen(listenv6, router) @@ -195,7 +195,7 @@ func main() { fs := http.FileServer(http.Dir(conf.WebServer.RootDir)) http.Handle("/", fs) for _, listen := range conf.WebServer.Listen { - if strings.ToLower(listen.Schema) == "https" { + if strings.ToLower(listen.Scheme) == "https" { go HttpListenWebServerTLS(listen.Addr, listen.CertFile, listen.KeyFile) } else { go HttpListenWebServer(listen.Addr)