-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement custom mux for Websocket servers #134
base: master
Are you sure you want to change the base?
Conversation
Note that I'm not sure this would be the best API for accomplishing this, but it was the easiest to get my code working. If this functionality is desired upstream I'm happy to implement it in another way pending a discussions of tradeoffs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the PR :-) |
// NewWebsocketServerTransport creates a new server-side transport. | ||
func NewWebsocketServerTransport(f ListenerFactory, path string, upgrader *websocket.Upgrader) ServerTransport { | ||
func NewWebsocketServerTransport(f ListenerFactory, path string, upgrader *websocket.Upgrader, mux *http.ServeMux) ServerTransport { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to keep the original NewWebsocketServerTransport
method signature, I think.
For example, extract a private method:
func innerNewWebsocketServerTransport(f ListenerFactory, path string, upgrader *websocket.Upgrader, mux *http.ServeMux) ServerTransport {
// original codes of NewWebsocketServerTransport
}
func NewWebsocketServerTransportWithMux(f ListenerFactory, path string, upgrader *websocket.Upgrader, mux *http.ServeMux) ServerTransport {
return innerNewWebsocketServerTransport(f,path,upgrader,mux)
}
func NewWebsocketServerTransport(f ListenerFactory, path string, upgrader *websocket.Upgrader) ServerTransport {
return innerNewWebsocketServerTransport(f,path,upgrader,nil)
}
Implement custom mux for Websocket servers
Motivation:
I need to serve other HTTP content on the same mux as the websocket used by RSocket
Modifications:
Added a function for creating a WebsocketServerTransport with a mux passed in
Result:
Nothing broken, just added another function