Splited Handler func + removed BiRPCRegister func

This commit is contained in:
porosnicuadrian
2021-01-27 18:03:44 +02:00
committed by Dan Christian Bogos
parent 37bac585ed
commit 0538c652d4
2 changed files with 6 additions and 7 deletions

View File

@@ -229,9 +229,7 @@ func (s *Server) ServeHTTP(addr string, jsonRPCURL string, wsRPCURL string,
s.httpEnabled = true
s.Unlock()
utils.Logger.Info("<HTTP> enabling handler for WebSocket connections")
wsHandler := websocket.Handler(func(ws *websocket.Conn) {
rpc.ServeCodec(newCapsJSONCodec(ws, s.caps, s.anz))
})
wsHandler := websocket.Handler(s.handleWebSocket)
if useBasicAuth {
s.httpMux.HandleFunc(wsRPCURL, use(wsHandler.ServeHTTP, basicAuth(userList)))
} else {
@@ -413,6 +411,10 @@ func (s *Server) ServeJSONTLS(addr, serverCrt, serverKey, caCert string,
s.serveCodecTLS(addr, utils.JSONCaps, serverCrt, serverKey, caCert, serverPolicy, serverName, newCapsJSONCodec, shdChan)
}
func (s *Server) handleWebSocket(ws *websocket.Conn) {
rpc.ServeCodec(newCapsJSONCodec(ws, s.caps, s.anz))
}
func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverPolicy int,
serverName string, jsonRPCURL string, wsRPCURL string,
useBasicAuth bool, userList map[string]string, shdChan *utils.SyncedChan) {
@@ -438,9 +440,7 @@ func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverP
s.httpEnabled = true
s.Unlock()
utils.Logger.Info("<HTTPS> enabling handler for WebSocket connections")
wsHandler := websocket.Handler(func(ws *websocket.Conn) {
rpc.ServeCodec(newCapsJSONCodec(ws, s.caps, s.anz))
})
wsHandler := websocket.Handler(s.handleWebSocket)
if useBasicAuth {
s.httpsMux.HandleFunc(wsRPCURL, use(wsHandler.ServeHTTP, basicAuth(userList)))
} else {

View File

@@ -34,7 +34,6 @@ type Server interface {
RegisterHttpFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
RegisterHttpHandler(pattern string, handler http.Handler)
BiRPCRegisterName(method string, handlerFunc interface{})
BiRPCRegister(rcvr interface{})
}
func LocalAddr() *NetAddr {