Skip to content

Commit

Permalink
Add Addr() method to server (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
fearful-symmetry authored Apr 4, 2024
1 parent e2cb821 commit baca41c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ func (s *Server) Shutdown(ctx context.Context) error {
return s.srv.Shutdown(ctx)
}

// Addr returns the network address of the server
// This is useful for tests, where we usually pass the port as `0` to get allocated a random free port
func (s *Server) Addr() net.Addr {
return s.l.Addr()
}

// AttachHandler will attach a handler at the specified route and return an error instead of panicing.
func (s *Server) AttachHandler(route string, h http.Handler) (err error) {
defer func() {
Expand Down

0 comments on commit baca41c

Please sign in to comment.