Change the RPC server to use it's own Muxer.

Rather than relying on the http package's DefaultServeMux for the RPC
server, create a unique mux specifically for the RPC server.  This ensures
things, such as the http profiling handlers, do not commingle.
This commit is contained in:
Dave Collins 2013-10-23 10:45:43 -05:00
parent 8970d4bf99
commit 5a4772bdc6

View file

@ -156,7 +156,9 @@ func (s *rpcServer) Start() {
} }
log.Trace("RPCS: Starting RPC server") log.Trace("RPCS: Starting RPC server")
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { rpcServeMux := http.NewServeMux()
httpServer := &http.Server{Handler: rpcServeMux}
rpcServeMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
login := s.username + ":" + s.password login := s.username + ":" + s.password
auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login)) auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login))
authhdr := r.Header["Authorization"] authhdr := r.Header["Authorization"]
@ -168,10 +170,9 @@ func (s *rpcServer) Start() {
} }
}) })
go s.walletListenerDuplicator() go s.walletListenerDuplicator()
http.Handle("/wallet", websocket.Handler(func(ws *websocket.Conn) { rpcServeMux.Handle("/wallet", websocket.Handler(func(ws *websocket.Conn) {
s.walletReqsNotifications(ws) s.walletReqsNotifications(ws)
})) }))
httpServer := &http.Server{}
for _, listener := range s.listeners { for _, listener := range s.listeners {
s.wg.Add(1) s.wg.Add(1)
go func(listener net.Listener) { go func(listener net.Listener) {