diff --git a/templates/go-swagger/app/templates/server/configureapi.gotmpl b/templates/go-swagger/app/templates/server/configureapi.gotmpl index 01a0702..be22516 100644 --- a/templates/go-swagger/app/templates/server/configureapi.gotmpl +++ b/templates/go-swagger/app/templates/server/configureapi.gotmpl @@ -51,6 +51,7 @@ type Config struct { {{ pascalize .Name }}API {{ end -}} Logger func(string, ...interface{}) + // InnerMiddleware is for the handler executors. These do not apply to the swagger.json document. // The middleware executes after routing but before authentication, binding and validation InnerMiddleware func(http.Handler) http.Handler diff --git a/templates/go-swagger/app/templates/server/main.gotmpl b/templates/go-swagger/app/templates/server/main.gotmpl index 13bcbd7..ba810aa 100644 --- a/templates/go-swagger/app/templates/server/main.gotmpl +++ b/templates/go-swagger/app/templates/server/main.gotmpl @@ -20,7 +20,7 @@ import ( // initTag is the signature of the function that tag initialization should respect. type initTag func(*restapi.Config) error -// tagswill be fulfill by init function in tag_XXX.go. +// tags will be fulfill by init function in tag_XXX.go. var tags = map[string]initTag{} func main() { @@ -33,6 +33,12 @@ func main() { logrus.WithError(err).Fatal("fail to initialize gocommon.log") } + // Initialize listenAddress + listenAddress, err := server.GetListenAddressFromEnvOrFlags() + if err != nil { + logger.WithError(err).Fatal("fail to initalize listenAddress") + } + // Initialize tracing logger.Info("Initializing tracing") tp, err := tracing.Init() @@ -62,8 +68,8 @@ func main() { } srv := http.Server{ - Addr: ":8081", - Handler: h, + Addr: listenAddress, + Handler: h, IdleTimeout: 30 * time.Second, ReadHeaderTimeout: 2 * time.Second, ReadTimeout: 1 * time.Second, diff --git a/templates/go-swagger/cmd/main.go.tmpl b/templates/go-swagger/cmd/main.go.tmpl deleted file mode 100644 index e69de29..0000000 diff --git a/templates/go-swagger/cmd/operation_group.go.tmpl b/templates/go-swagger/cmd/operation_group.go.tmpl deleted file mode 100644 index e69de29..0000000