Skip to content

Commit 91e2dd1

Browse files
committed
Added support to proxy paths.
1 parent cbab5f8 commit 91e2dd1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

websocketproxy.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,14 @@ func ProxyHandler(target *url.URL) http.Handler {
5252
// NewProxy returns a new Websocket reverse proxy that rewrites the
5353
// URL's to the scheme, host and base path provider in target.
5454
func NewProxy(target *url.URL) *WebsocketProxy {
55-
backend := func(r *http.Request) *url.URL { return target }
55+
backend := func(r *http.Request) *url.URL {
56+
// Shallow copy
57+
u := *target
58+
u.Fragment = r.URL.Fragment
59+
u.Path = r.URL.Path
60+
u.RawQuery = r.URL.RawQuery
61+
return &u
62+
}
5663
return &WebsocketProxy{Backend: backend}
5764
}
5865

0 commit comments

Comments
 (0)