From 90ea4a73ada3b583cdad8b133d43369a4042d782 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 28 Mar 2025 11:13:20 +0000 Subject: [PATCH] lib/http: add Addr() method to return the first configured server address --- lib/http/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/http/server.go b/lib/http/server.go index 57ce8b8bb..98f4f5ca7 100644 --- a/lib/http/server.go +++ b/lib/http/server.go @@ -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