完善Nacos注册逻辑

This commit is contained in:
李寻欢 2021-09-09 13:54:39 +08:00
parent e973fea5f3
commit c8af406b04
2 changed files with 3 additions and 21 deletions

View File

@ -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())
}

18
main.go
View File

@ -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))
}