proxy/http.go
func HTTPReverseProxy(options Options) (int, error) {
	port := options.ProxyPort
	var err error

	proxy := httputil.NewSingleHostReverseProxy(&url.URL{
		Scheme: options.TargetScheme,
		Host:   options.TargetAddress,
	})

	if port == 0 {
		port, err = utils.GetFreePort()
		if err != nil {
			log.Println("[ERROR] unable to start reverse proxy server:", err)
			return 0, err
		}
	}

	wrapper := chainHandlers(append(options.Middleware, loggingMiddleware)...)

	log.Println("[DEBUG] starting reverse proxy on port", port)
	go http.ListenAndServe(fmt.Sprintf(":%d", port), wrapper(proxy))

	return port, nil
}
func HTTPReverseProxy(options Options) (int, error) {
	port := options.ProxyPort
	var err error

	proxy := httputil.NewSingleHostReverseProxy(&url.URL{
		Scheme: options.TargetScheme,
		Host:   options.TargetAddress,
	})

	if port == 0 {
		port, err = utils.GetFreePort()
		if err != nil {
			log.Println("[ERROR] unable to start reverse proxy server:", err)
			return 0, err
		}
	}

	wrapper := chainHandlers(append(options.Middleware, loggingMiddleware)...)

	log.Println("[DEBUG] starting reverse proxy on port", port)
	go http.ListenAndServe(fmt.Sprintf(":%d", port), wrapper(proxy))

	return port, nil
}
// HTTPReverseProxy provides a default setup for proxying
// internal components within the framework