From 973e598cf9e9da44ced06d25739d921771febca2 Mon Sep 17 00:00:00 2001 From: Janishar Ali Date: Tue, 2 Jul 2024 01:22:26 +0530 Subject: [PATCH] fix nats subject map for endpoint --- arch/micro/router.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/micro/router.go b/arch/micro/router.go index 6b25d4f..0ab9a38 100644 --- a/arch/micro/router.go +++ b/arch/micro/router.go @@ -43,7 +43,11 @@ func (r *router) LoadControllers(controllers []Controller) { natsClient := r.natsClient.GetInstance() for _, c := range controllers { - baseSub := fmt.Sprintf(`%s.%s`, natsClient.Service.Info().Name, strings.ReplaceAll(c.Path(), "/", "")) + baseSub := natsClient.Service.Info().Name + endpoint := strings.ReplaceAll(c.Path(), "/", ".") + if len(endpoint) > 1 { + baseSub = fmt.Sprintf(`%s%s`, baseSub, endpoint) + } ng := natsClient.Service.AddGroup(baseSub) c.MountNats(ng)