diff --git a/routes/routes.go b/routes/routes.go index 5cbe066..f0ea6f4 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -7,52 +7,30 @@ import ( ) type Routes struct { - innerMethods map[string]bool - allMethods map[string]bool - authUserMethods map[string]bool + innerMethods map[string]bool } func NewRoutes() *Routes { return &Routes{ - innerMethods: make(map[string]bool), - allMethods: make(map[string]bool), - authUserMethods: make(map[string]bool), + innerMethods: make(map[string]bool), } } func (s *Routes) ReceiveRoutes(ctx context.Context, routes cluster.RoutingConfig) error { - newAddressMap := make(map[string]bool) - newInnerAddressMap := make(map[string]bool) - newAuthUserAddressMap := make(map[string]bool) + newInnerMethods := make(map[string]bool) for _, backend := range routes { - if backend.Address.IP == "" || backend.Address.Port == "" || len(backend.Endpoints) == 0 { - continue - } for _, v := range backend.Endpoints { - newAddressMap[v.Path] = true if v.Inner { - newInnerAddressMap[v.Path] = true - } - if v.UserAuthRequired { - newAuthUserAddressMap[v.Path] = true + newInnerMethods[v.Path] = true } } } - s.allMethods = newAddressMap - s.innerMethods = newInnerAddressMap - s.authUserMethods = newAuthUserAddressMap + + s.innerMethods = newInnerMethods return nil } -func (s *Routes) IsAvailableMethod(path string) bool { - return s.allMethods[path] -} - -func (s *Routes) IsAuthUserMethod(path string) bool { - return s.authUserMethods[path] -} - func (s *Routes) IsInnerMethod(path string) bool { return s.innerMethods[path] }