Skip to content

Commit d87c8d9

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 61bca8a commit d87c8d9

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
@@ -285,6 +285,23 @@ func (s *Manager) ReadRemoteMacaroon(uri string) (bool, []byte, error) {
285285
return false, nil, nil
286286
}
287287

288+
// Handles returns true if one of its sub-servers owns the given URI along with
289+
// the name of the service.
290+
func (s *Manager) Handles(uri string) (bool, string) {
291+
s.mu.RLock()
292+
defer s.mu.RUnlock()
293+
294+
for _, ss := range s.servers {
295+
if !s.permsMgr.IsSubServerURI(ss.Name(), uri) {
296+
continue
297+
}
298+
299+
return true, ss.Name()
300+
}
301+
302+
return false, ""
303+
}
304+
288305
// Stop stops all the manager's sub-servers
289306
func (s *Manager) Stop() error {
290307
var returnErr error

0 commit comments

Comments
 (0)