File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -56,15 +56,18 @@ func NewProxy(target *url.URL) *WebsocketProxy {
56
56
return & WebsocketProxy {Backend : backend }
57
57
}
58
58
59
- func (w * WebsocketProxy ) CloseNotify () {
60
- }
61
-
62
59
// ServeHTTP implements the http.Handler that proxies WebSocket connections.
63
60
func (w * WebsocketProxy ) ServeHTTP (rw http.ResponseWriter , req * http.Request ) {
61
+ if w .Backend == nil {
62
+ log .Println ("websocketproxy: backend function is not defined" )
63
+ http .Error (rw , "internal server error (code: 1)" , http .StatusInternalServerError )
64
+ return
65
+ }
66
+
64
67
backendURL := w .Backend (req )
65
68
if backendURL == nil {
66
69
log .Println ("websocketproxy: backend URL is nil" )
67
- http .Error (rw , "internal server error" , http .StatusInternalServerError )
70
+ http .Error (rw , "internal server error (code: 2) " , http .StatusInternalServerError )
68
71
return
69
72
}
70
73
You can’t perform that action at this time.
0 commit comments