lib/http: add Addr() method to return the first configured server address

This commit is contained in:
Nick Craig-Wood 2025-03-28 11:13:20 +00:00
parent efe8ac8f35
commit 90ea4a73ad

View File

@ -576,6 +576,14 @@ func (s *Server) URLs() []string {
return out
}
// Addr returns the first configured address
func (s *Server) Addr() net.Addr {
if len(s.instances) == 0 || s.instances[0].listener == nil {
return nil
}
return s.instances[0].listener.Addr()
}
// UsingAuth returns true if authentication is required
func (s *Server) UsingAuth() bool {
return s.usingAuth