From c8af406b043f1531fb21f30a3a23492a641c63b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AF=BB=E6=AC=A2?= Date: Thu, 9 Sep 2021 13:54:39 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=AE=8C=E5=96=84Nacos=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- initialization/nacos.go | 6 +++--- main.go | 18 ------------------ 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/initialization/nacos.go b/initialization/nacos.go index eb31f67..e3dd104 100644 --- a/initialization/nacos.go +++ b/initialization/nacos.go @@ -35,7 +35,7 @@ func initNacos() { if err != nil { panic(err) } - ip := "gateway" + ip := config.AppInfo.AppName if ips := utils.GetIps(); ips != nil { ip = ips[0] } @@ -45,7 +45,7 @@ func initNacos() { Weight: 10, Enable: true, Healthy: true, - ServiceName: "gateway", + ServiceName: config.AppInfo.AppName, Ephemeral: true, }) core.Log.Debug("Nacos注册结果: %v", success) @@ -80,7 +80,7 @@ func initNacos() { // 读取初始配置 core.NacosClient = core.NewNacosClient(client, configClient) - configStr, err := configClient.GetConfig(vo.ConfigParam{DataId: "gateway.yml", Group: "DEFAULT_GROUP"}) + configStr, err := configClient.GetConfig(vo.ConfigParam{DataId: config.NacosConfig.CenterConfigName, Group: "DEFAULT_GROUP"}) if err != nil { core.Log.Panic("读取配置文件错误: %v", err.Error()) } diff --git a/main.go b/main.go index 5327bd8..4d4ccbc 100644 --- a/main.go +++ b/main.go @@ -19,23 +19,5 @@ func main() { app.Any("/*action", core.NacosClient.Remote) - //app.GET("/hello", func(context *gin.Context) { - // dd := context.GetString("UberTraceId") - // //log.Println("数据是否存在: ", boo) - // //if boo { - // // log.Println(dd) - // //} - // context.String(http.StatusOK, get("get", context.Request.RequestURI, context.GetString("X-Request-Id"), dd)) - //}) - // - //app.POST("/hello", func(context *gin.Context) { - // context.String(http.StatusOK, post(context.Request.RequestURI)) - //}) - // - //app.GET("/ip", func(context *gin.Context) { - // dd := context.GetString("UberTraceId") - // context.String(http.StatusOK, get("get", context.Request.RequestURI, context.GetString("X-Request-Id"), dd)) - //}) - _ = app.Run(fmt.Sprintf(":%v", config.AppInfo.Port)) }