func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy {
	targetQuery := target.RawQuery
	director := func(req *http.Request) {
		req.URL.Scheme = target.Scheme
		req.URL.Host = target.Host
		req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path)
		if targetQuery == "" || req.URL.RawQuery == "" {
			req.URL.RawQuery = targetQuery + req.URL.RawQuery
		} else {
			req.URL.RawQuery = targetQuery + "&" + req.URL.RawQuery
		}
	}
	return &ReverseProxy{Director: director}
}
NewSingleHostReverseProxy returns a new websocket ReverseProxy. The path
rewrites follow the same rules as the httputil.ReverseProxy. If the target
url has the path '/foo' and the incoming request '/bar', the request path
will be updated to '/foo/bar' before forwarding.
Scheme should specify if 'ws' or 'wss' should be used.
package wsutil
import (
	"crypto/tls"
	"io"
	"log"
	"net"
	"net/http"
	"net/url"
	"strings"
)
type ReverseProxy struct {
	Director func(*http.Request)
	Dial func(network, addr string) (net.Conn, error)
	TLSClientConfig *tls.Config
	ErrorLog *log.Logger
}
func singleJoiningSlash(a, b string) string {
	aslash := strings.HasSuffix(a, "/")
	bslash := strings.HasPrefix(b, "/")
	switch {
	case aslash && bslash:
		return a + b[1:]
	case !aslash && !bslash:
		return a + "/" + b
	}
	return a + b
}