func serverSetup(t *testing.T, addr string) func() {
	handler := func(w nethttp.ResponseWriter, req *nethttp.Request) {
		statusCode := statusFromPath(req.URL.Path)
		io.Copy(ioutil.Discard, req.Body)
		w.WriteHeader(statusCode)
	}

	srv := &nethttp.Server{
		Addr:         addr,
		Handler:      nethttp.HandlerFunc(handler),
		ReadTimeout:  time.Second,
		WriteTimeout: time.Second,
	}

	srv.SetKeepAlivesEnabled(false)

	go func() {
		_ = srv.ListenAndServe()
	}()

	return func() { srv.Shutdown(context.Background()) }
}
// serverSetup spins up a HTTP test server that returns the status code included in the URL
// Example:
// * GET /200/foo returns a 200 status code;
// * PUT /404/bar returns a 404 status code;
serverSetup spins up a HTTP test server that returns the status code included in the URL
Example:
GET /200/foo returns a 200 status code;
PUT /404/bar returns a 404 status code.
// serverSetup spins up a HTTP test server that returns the status code included in the URL // Example : // * GET / 200 / foo returns a 200 status code ; // * PUT / 404 / bar returns a 404 status code ;
func serverSetup(t *testing.T, addr string) func() {
	handler := func(w nethttp.ResponseWriter, req *nethttp.Request) {
		statusCode := statusFromPath(req.URL.Path)
		io.Copy(ioutil.Discard, req.Body)
		w.WriteHeader(statusCode)
	}
	srv := &nethttp.Server{
		Addr:         addr,
		Handler:      nethttp.HandlerFunc(handler),
		ReadTimeout:  time.Second,
		WriteTimeout: time.Second,
	}
	srv.SetKeepAlivesEnabled(false)
	go func() {
		_ = srv.ListenAndServe()
	}()
	return func() { srv.Shutdown(context.Background()) }
}
func serverSetup ( t * testing . T , addr string ) func ( ) { handler := func ( w nethttp . ResponseWriter , req * nethttp . Request ) { statusCode := statusFromPath ( req . URL . Path ) io . Copy ( ioutil . Discard , req . Body ) w . WriteHeader ( statusCode ) } srv := & nethttp . Server { Addr : addr , Handler : nethttp . HandlerFunc ( handler ) , ReadTimeout : time . Second , WriteTimeout : time . Second , } srv . SetKeepAlivesEnabled ( false ) go func ( ) { _ = srv . ListenAndServe ( ) } ( ) return func ( ) { srv . Shutdown ( context . Background ( ) ) } }
serverSetup spins up a HTTP test server that returns the status code included in the URL
Example:
GET /200/foo returns a 200 status code;
PUT /404/bar returns a 404 status code.
serverSetup spins up a HTTP test server that returns the status code included in the URL Example : GET / 200 / foo returns a 200 status code ; PUT / 404 / bar returns a 404 status code .