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.
This commit is contained in:
Elle Mouton 2023-05-03 10:00:55 +02:00
parent 3769467c24
commit 21456a5887
No known key found for this signature in database
GPG key ID: D7D916376026F177

View file

@ -300,6 +300,23 @@ func (s *Manager) ReadRemoteMacaroon(uri string) (bool, []byte, error) {
return false, nil, nil
}
// Handles returns true if one of its sub-servers owns the given URI along with
// the name of the service.
func (s *Manager) Handles(uri string) (bool, string) {
s.mu.RLock()
defer s.mu.RUnlock()
for _, ss := range s.servers {
if !s.permsMgr.IsSubServerURI(ss.Name(), uri) {
continue
}
return true, ss.Name()
}
return false, ""
}
// Stop stops all the manager's sub-servers
func (s *Manager) Stop() error {
var returnErr error