func (s *Server) Shutdown(ctx context.Context) error {
	ticker := time.NewTicker(shutdownPollInterval)
	defer ticker.Stop()
	for {
		if s.noActiveConnections() {
			return nil
		}
		select {
		case <-ctx.Done():
			return ctx.Err()
		case <-ticker.C:
		}
	}
}
Shutdown blocks until all connections have completed.
Note that this will not actually close the listener, since we don't have
access to it here. Instead, it is assumed that the caller has already
closed the underlying listener prior to calling Shutdown.
package h2c
import (
	"bufio"
	"context"
	"net"
	"net/http"
	"strings"
	"sync"
	"time"
	"golang.org/x/net/http2"
)
const shutdownPollInterval = 500 * time.Millisecond
type Server struct {
	HTTP2Handler      http.Handler
	NonUpgradeHandler http.Handler
	ALBSupport bool
	connections   map[net.Conn]struct{}
	connectionsMu sync.Mutex
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	connection, upgrade := r.Header.Get("Connection"), r.Header.Get("Upgrade")
	if !s.isH2C(connection, upgrade) {
		s.NonUpgradeHandler.ServeHTTP(w, r)
		return
	}
	hj, ok := w.(http.Hijacker)
	if !ok {
		http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError)
		return
	}
	w.Header().Set("Connection", "Upgrade")
	w.Header().Set("Upgrade", "h2c")
	w.WriteHeader(http.StatusSwitchingProtocols)
	conn, bufrw, err := hj.Hijack()
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	s.trackConn(conn, true)
	defer s.trackConn(conn, false)
	new(http2.Server).ServeConn(bufConn{conn, bufrw}, &http2.ServeConnOpts{
		Handler: s.HTTP2Handler,
	})
}