http_defaults.go
func WithDefaults(srv *http.Server) *http.Server {
	if srv.TLSConfig == nil {
		srv.TLSConfig = &tls.Config{}
	}

	srv.TLSConfig.PreferServerCipherSuites = true
	srv.TLSConfig.MinVersion = DefaultMinVersion
	srv.TLSConfig.CurvePreferences = DefaultCurvePreferences
	srv.TLSConfig.CipherSuites = DefaultCipherSuites

	if srv.ReadTimeout == 0 {
		srv.ReadTimeout = DefaultReadTimeout
	}

	if srv.WriteTimeout == 0 {
		srv.WriteTimeout = DefaultWriteTimeout
	}

	if srv.IdleTimeout == 0 {
		srv.IdleTimeout = DefaultIdleTimeout
	}

	return srv
}
func WithDefaults(srv *http.Server) *http.Server {
	if srv.TLSConfig == nil {
		srv.TLSConfig = &tls.Config{}
	}

	srv.TLSConfig.PreferServerCipherSuites = true
	srv.TLSConfig.MinVersion = DefaultMinVersion
	srv.TLSConfig.CurvePreferences = DefaultCurvePreferences
	srv.TLSConfig.CipherSuites = DefaultCipherSuites

	if srv.ReadTimeout == 0 {
		srv.ReadTimeout = DefaultReadTimeout
	}

	if srv.WriteTimeout == 0 {
		srv.WriteTimeout = DefaultWriteTimeout
	}

	if srv.IdleTimeout == 0 {
		srv.IdleTimeout = DefaultIdleTimeout
	}

	return srv
}
func WithDefaults ( srv * http . Server ) * http . Server { if srv . TLSConfig == nil { srv . TLSConfig = & tls . Config { } } srv . TLSConfig . PreferServerCipherSuites = true srv . TLSConfig . MinVersion = DefaultMinVersion srv . TLSConfig . CurvePreferences = DefaultCurvePreferences srv . TLSConfig . CipherSuites = DefaultCipherSuites if srv . ReadTimeout == 0 { srv . ReadTimeout = DefaultReadTimeout } if srv . WriteTimeout == 0 { srv . WriteTimeout = DefaultWriteTimeout } if srv . IdleTimeout == 0 { srv . IdleTimeout = DefaultIdleTimeout } return srv }
// WithDefaults patches a http.Server based on a best practice configuration
// from Cloudflare: https://blog.cloudflare.com/exposing-go-on-the-internet/
//
// You can override the defaults by mutating the Default* variables exposed
// by this package
WithDefaults patches a http . Server based on a best practice configuration from Cloudflare : https : // blog . cloudflare . com / exposing - go - on - the - internet / You can override the defaults by mutating the Default * variables exposed by this package