File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
Expand file tree Collapse file tree 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 {
5656 return & WebsocketProxy {Backend : backend }
5757}
5858
59- func (w * WebsocketProxy ) CloseNotify () {
60- }
61-
6259// ServeHTTP implements the http.Handler that proxies WebSocket connections.
6360func (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+
6467 backendURL := w .Backend (req )
6568 if backendURL == nil {
6669 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 )
6871 return
6972 }
7073
You can’t perform that action at this time.
0 commit comments