Which pattern correctly waits for in-flight HTTP requests to finish before exiting?
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
defer stop()
// ... server.ListenAndServe() in a goroutine ...
<-ctx.Done()
shutdownCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
srv.Shutdown(shutdownCtx)