Skip to content

Commit 21456a5

Browse files
committed
subservers: add Handles method
Add a Handles method to the subserver Manager which takes a URI string and returns true if one of the sub-servers it manages owns the given URI.
1 parent 3769467 commit 21456a5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

subservers/manager.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,23 @@ func (s *Manager) ReadRemoteMacaroon(uri string) (bool, []byte, error) {
300300
return false, nil, nil
301301
}
302302

303+
// Handles returns true if one of its sub-servers owns the given URI along with
304+
// the name of the service.
305+
func (s *Manager) Handles(uri string) (bool, string) {
306+
s.mu.RLock()
307+
defer s.mu.RUnlock()
308+
309+
for _, ss := range s.servers {
310+
if !s.permsMgr.IsSubServerURI(ss.Name(), uri) {
311+
continue
312+
}
313+
314+
return true, ss.Name()
315+
}
316+
317+
return false, ""
318+
}
319+
303320
// Stop stops all the manager's sub-servers
304321
func (s *Manager) Stop() error {
305322
var returnErr error

0 commit comments

Comments
 (0)