koding / websocketproxy

WebSocket reverse proxy handler for Go
http://godoc.org/github.com/koding/websocketproxy
MIT License
427 stars 120 forks source link

Write error status when WebSocket dial fails #21

Closed janmiderback closed 6 years ago

janmiderback commented 6 years ago

https://github.com/koding/websocketproxy/blob/944ae4ae170f3afa1e0683bcc3230d34c21e70eb/websocketproxy.go#L134

When the Dial() fails, my suggestion is to write 503 Service Unavailable to the ResponseWriter.

The typical use case would be when writing middleware, wrapping the ResponseWriter and acting on possible failures in upgrade or dial. With this addition that would be possible. If there are better ways to solve the error mode, I'd appreciate comments on the better way to handle it.

If the change would be accepted, I could do the PR, if added to contributors.

janmiderback commented 6 years ago

This https://github.com/koding/websocketproxy/pull/20/files would solve it! Closing.