From 73e5d4cb4edbfd79b3436f65451dc1d8a19ee95b Mon Sep 17 00:00:00 2001 From: william feng <> Date: Mon, 10 Aug 2020 18:06:42 +0800 Subject: [PATCH] get application from both dir.url and dir.url.suburl --- cluster/directory/base_directory.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cluster/directory/base_directory.go b/cluster/directory/base_directory.go index 651c90ff6..20db1f2b7 100644 --- a/cluster/directory/base_directory.go +++ b/cluster/directory/base_directory.go @@ -112,11 +112,15 @@ func (dir *BaseDirectory) SetRouters(urls []*common.URL) { func (dir *BaseDirectory) isProperRouter(url *common.URL) bool { app := url.GetParam(constant.APPLICATION_KEY, "") + dirApp := dir.GetUrl().GetParam(constant.APPLICATION_KEY, "") + if len(dirApp) == 0 && dir.GetUrl().SubURL != nil { + dirApp = dir.GetUrl().SubURL.GetParam(constant.APPLICATION_KEY, "") + } serviceKey := dir.GetUrl().ServiceKey() - if serviceKey == "" { + if len(serviceKey) == 0 { serviceKey = dir.GetUrl().SubURL.ServiceKey() } - if len(app) > 0 && app == dir.GetUrl().GetParam(constant.APPLICATION_KEY, "") { + if len(app) > 0 && app == dirApp { return true } if url.ServiceKey() == serviceKey { -- GitLab