func httpsRedirectHandler(httpsPort int) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		host := r.Host
		// derived from net.SplitHostPort, but does not throw error :
		lastColonIndex := strings.LastIndex(host, ":")
		if lastColonIndex >= 0 {
			host = host[:lastColonIndex]
		}
		if httpsPort != 443 {
			host += fmt.Sprintf(":%d", httpsPort)
		}
		httpsURI := "https://" + host + r.URL.Path
		http.Redirect(w, r, httpsURI, http.StatusMovedPermanently)
	}
}
// httpsRedirectHandler redirects the request to https.
httpsRedirectHandler redirects the request to https.
// httpsRedirectHandler redirects the request to https .
func httpsRedirectHandler(httpsPort int) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		host := r.Host
		lastColonIndex := strings.LastIndex(host, ":")
		if lastColonIndex >= 0 {
			host = host[:lastColonIndex]
		}
		if httpsPort != 443 {
			host += fmt.Sprintf(":%d", httpsPort)
		}
		httpsURI := "https://" + host + r.URL.Path
		http.Redirect(w, r, httpsURI, http.StatusMovedPermanently)
	}
}
func httpsRedirectHandler ( httpsPort int ) http . HandlerFunc { return func ( w http . ResponseWriter , r * http . Request ) { host := r . Host lastColonIndex := strings . LastIndex ( host , " " ) if lastColonIndex >= 0 { host = host [ : lastColonIndex ] } if httpsPort != 443 { host += fmt . Sprintf ( " " , httpsPort ) } httpsURI := " " + host + r . URL . Path http . Redirect ( w , r , httpsURI , http . StatusMovedPermanently ) } }
httpsRedirectHandler redirects the request to https.
httpsRedirectHandler redirects the request to https .
// derived from net.SplitHostPort, but does not throw error :