Proposed change
move
func(w http.ResponseWriter, r *http.Request) {
res, err := s.wsUpgrade(w, r)
if err != nil {
s.Errorf(err.Error())
return
}
switch res.kind {
case CLIENT:
s.createWSClient(res.conn, res.ws)
case MQTT:
s.createMQTTClient(res.conn, res.ws)
case LEAF:
if !hasLeaf {
s.Errorf("Not configured to accept leaf node connections")
// Silently close for now. If we want to send an error back, we would
// need to create the leafnode client anyway, so that is handling websocket
// frames, then send the error to the remote.
res.conn.Close()
return
}
s.createLeafNode(res.conn, nil, nil, res.ws)
}
}
into a dedicated, exported function like (similar to e.g. server.HandleVarz)
func (s *Server) HandleWsUpgrade(w http.ResponseWriter, r *http.Request) {
Use case
I want to embedd into my application.
This will also run in environments like windows in customer networks, where it is administratively challenging to open additional ports.
My app serves browser clients, where I would like to connect to nats via WSS (maybe also mqtt).
I would like to include selective nats REST endpoints into my existing "outward" facing http router, so I have to secure only one.
Contribution
sure, can contribute .. but feels a bit trivial .. except if there are any indirect effects, e.g. if anywhere is a redirect/forward/origin URL that would also have to be adjusted, which I would not know.
Proposed change
move
into a dedicated, exported function like (similar to e.g. server.HandleVarz)
func (s *Server) HandleWsUpgrade(w http.ResponseWriter, r *http.Request) {Use case
I want to embedd into my application.
This will also run in environments like windows in customer networks, where it is administratively challenging to open additional ports.
My app serves browser clients, where I would like to connect to nats via WSS (maybe also mqtt).
I would like to include selective nats REST endpoints into my existing "outward" facing http router, so I have to secure only one.
Contribution
sure, can contribute .. but feels a bit trivial .. except if there are any indirect effects, e.g. if anywhere is a redirect/forward/origin URL that would also have to be adjusted, which I would not know.