func (s *Server) Listen() (cancel func()) {
	var wg sync.WaitGroup
	wg.Add(1)

	ln, err := net.Listen("tcp", s.srv.Addr)
	if err != nil {
		s.t.Fatalf("ListenFederationServer: net.Listen failed: %s", err)
	}

	go func() {
		defer ln.Close()
		defer wg.Done()
		err := s.srv.ServeTLS(ln, s.certPath, s.keyPath)
		if err != nil && err != http.ErrServerClosed {
			s.t.Logf("ListenFederationServer: ServeTLS failed: %s", err)
			// Note that running s.t.FailNow is not allowed in a separate goroutine
			// Tests will likely fail if the server is not listening anyways
		}
	}()

	return func() {
		err := s.srv.Shutdown(context.Background())
		if err != nil {
			s.t.Fatalf("ListenFederationServer: failed to shutdown server: %s", err)
		}
		wg.Wait() // wait for the server to shutdown
	}
}
// Listen for federation server requests - call the returned function to gracefully close the server.
Listen for federation server requests - call the returned function to gracefully close the server.
// Listen for federation server requests - call the returned function to gracefully close the server .
func (s *Server) Listen() (cancel func()) {
	var wg sync.WaitGroup
	wg.Add(1)
	ln, err := net.Listen("tcp", s.srv.Addr)
	if err != nil {
		s.t.Fatalf("ListenFederationServer: net.Listen failed: %s", err)
	}
	go func() {
		defer ln.Close()
		defer wg.Done()
		err := s.srv.ServeTLS(ln, s.certPath, s.keyPath)
		if err != nil && err != http.ErrServerClosed {
			s.t.Logf("ListenFederationServer: ServeTLS failed: %s", err)
		}
	}()
	return func() {
		err := s.srv.Shutdown(context.Background())
		if err != nil {
			s.t.Fatalf("ListenFederationServer: failed to shutdown server: %s", err)
		}
		wg.Wait() 
	}
}
func ( s * Server ) Listen ( ) ( cancel func ( ) ) { var wg sync . WaitGroup wg . Add ( 1 ) ln , err := net . Listen ( " " , s . srv . Addr ) if err != nil { s . t . Fatalf ( " " , err ) } go func ( ) { defer ln . Close ( ) defer wg . Done ( ) err := s . srv . ServeTLS ( ln , s . certPath , s . keyPath ) if err != nil && err != http . ErrServerClosed { s . t . Logf ( " " , err ) } } ( ) return func ( ) { err := s . srv . Shutdown ( context . Background ( ) ) if err != nil { s . t . Fatalf ( " " , err ) } wg . Wait ( ) } }
Listen for federation server requests - call the returned function to gracefully close the server.
Listen for federation server requests - call the returned function to gracefully close the server .
// Note that running s.t.FailNow is not allowed in a separate goroutine // Tests will likely fail if the server is not listening anyways // wait for the server to shutdown