nacos config

This commit is contained in:
eson
2023-09-19 11:41:38 +08:00
parent d7f94f0da9
commit b4672bbed7
29 changed files with 208 additions and 124 deletions

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/auth/internal/config"
"fusenapi/server/auth/internal/handler"
@@ -20,8 +21,10 @@ var configFile = flag.String("f", "etc/auth.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))
defer server.Stop()

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/base/internal/config"
"fusenapi/server/base/internal/handler"
@@ -20,8 +21,9 @@ var configFile = flag.String("f", "etc/base.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/canteen/internal/handler"
"fusenapi/server/canteen/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,9 +20,9 @@ var configFile = flag.String("f", "etc/canteen.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -9,7 +9,6 @@ import (
"fusenapi/utils/auth"
"net/http"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
)
@@ -19,7 +18,6 @@ func main() {
flag.Parse()
var c config2.Config
conf.MustLoad(*configFile, &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/home-user-auth/internal/handler"
"fusenapi/server/home-user-auth/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,9 +20,9 @@ var configFile = flag.String("f", "etc/home-user-auth.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -7,6 +7,7 @@ import (
"time"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/info/internal/config"
"fusenapi/server/info/internal/handler"
@@ -21,8 +22,10 @@ var configFile = flag.String("f", "etc/info.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/map-library/internal/handler"
"fusenapi/server/map-library/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/map-library.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/pay/internal/config"
"fusenapi/server/pay/internal/handler"
@@ -20,8 +21,10 @@ var configFile = flag.String("f", "etc/pay.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))
defer server.Stop()

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/product-model/internal/handler"
"fusenapi/server/product-model/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/product-model.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/product-template-tag/internal/config"
"fusenapi/server/product-template-tag/internal/handler"
@@ -20,8 +21,10 @@ var configFile = flag.String("f", "etc/product-template-tag.yaml", "the config f
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))
defer server.Stop()

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/product-template/internal/handler"
"fusenapi/server/product-template/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/product-template.yaml", "the config file"
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/product/internal/handler"
"fusenapi/server/product/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/product.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -6,6 +6,7 @@ import (
"net/http"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/resource/internal/config"
"fusenapi/server/resource/internal/handler"
@@ -20,8 +21,10 @@ var configFile = flag.String("f", "etc/resource.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))
defer server.Stop()

View File

@@ -7,6 +7,7 @@ import (
"time"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/shopping-cart/internal/config"
"fusenapi/server/shopping-cart/internal/handler"
@@ -21,8 +22,10 @@ var configFile = flag.String("f", "etc/shopping-cart.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
c.Timeout = int64(time.Second * 15)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/upload/internal/handler"
"fusenapi/server/upload/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/upload.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -9,6 +9,7 @@ import (
"fusenapi/server/webset/internal/handler"
"fusenapi/server/webset/internal/svc"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/rest"
@@ -19,8 +20,9 @@ var configFile = flag.String("f", "etc/webset.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {

View File

@@ -8,6 +8,7 @@ import (
"net/http"
"fusenapi/utils/auth"
"fusenapi/utils/fsconfig"
"fusenapi/server/websocket/internal/config"
"fusenapi/server/websocket/internal/handler"
@@ -22,8 +23,10 @@ var configFile = flag.String("f", "etc/websocket.yaml", "the config file")
func main() {
flag.Parse()
cfgContent := fsconfig.StartNacosConfig(*configFile, nil)
var c config.Config
conf.MustLoad(*configFile, &c)
conf.LoadConfigFromYamlBytes([]byte(cfgContent), &c)
server := rest.MustNewServer(c.RestConf, rest.WithCustomCors(auth.FsCors, func(w http.ResponseWriter) {
}))
defer server.Stop()