✨ 完善Nacos注册逻辑
This commit is contained in:
parent
e973fea5f3
commit
c8af406b04
@ -35,7 +35,7 @@ func initNacos() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ip := "gateway"
|
ip := config.AppInfo.AppName
|
||||||
if ips := utils.GetIps(); ips != nil {
|
if ips := utils.GetIps(); ips != nil {
|
||||||
ip = ips[0]
|
ip = ips[0]
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ func initNacos() {
|
|||||||
Weight: 10,
|
Weight: 10,
|
||||||
Enable: true,
|
Enable: true,
|
||||||
Healthy: true,
|
Healthy: true,
|
||||||
ServiceName: "gateway",
|
ServiceName: config.AppInfo.AppName,
|
||||||
Ephemeral: true,
|
Ephemeral: true,
|
||||||
})
|
})
|
||||||
core.Log.Debug("Nacos注册结果: %v", success)
|
core.Log.Debug("Nacos注册结果: %v", success)
|
||||||
@ -80,7 +80,7 @@ func initNacos() {
|
|||||||
|
|
||||||
// 读取初始配置
|
// 读取初始配置
|
||||||
core.NacosClient = core.NewNacosClient(client, configClient)
|
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 {
|
if err != nil {
|
||||||
core.Log.Panic("读取配置文件错误: %v", err.Error())
|
core.Log.Panic("读取配置文件错误: %v", err.Error())
|
||||||
}
|
}
|
||||||
|
18
main.go
18
main.go
@ -19,23 +19,5 @@ func main() {
|
|||||||
|
|
||||||
app.Any("/*action", core.NacosClient.Remote)
|
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))
|
_ = app.Run(fmt.Sprintf(":%v", config.AppInfo.Port))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user