removing unnecessary function

This commit is contained in:
renaynay 2020-03-25 19:14:33 +01:00
parent 3de74d2213
commit a305f5a08c
No known key found for this signature in database
GPG key ID: 731E44FAAFCD0274

View file

@ -20,7 +20,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"net" "net"
"net/http"
"os" "os"
"path/filepath" "path/filepath"
"reflect" "reflect"
@ -377,12 +376,11 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
return err // TODO this should return upon failure, right? return err // TODO this should return upon failure, right?
} }
var ws http.Handler handler := NewHTTPHandlerStack(srv, cors, vhosts)
if n.httpEndpoint == n.wsEndpoint {
ws = srv.WebsocketHandler(wsOrigins)
}
// wrap handler in websocket handler only if websocket port is the same as http rpc // wrap handler in websocket handler only if websocket port is the same as http rpc
handler := n.AddWebsocketHandler(NewHTTPHandlerStack(srv, cors, vhosts), ws) if n.httpEndpoint == n.wsEndpoint {
handler = NewWebsocketUpgradeHandler(handler, srv.WebsocketHandler(wsOrigins))
}
listener, err := rpc.StartHTTPEndpoint(endpoint, timeouts, handler) listener, err := rpc.StartHTTPEndpoint(endpoint, timeouts, handler)
if err != nil { if err != nil {
@ -402,15 +400,6 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
return nil return nil
} }
// AddWebsocketHandler creates the handler stack necessary to handle both http rpc requests and websocket requests
func (n *Node) AddWebsocketHandler(handler http.Handler, websocket http.Handler) http.Handler {
if websocket != nil {
return NewWebsocketUpgradeHandler(handler, websocket)
}
return handler
}
// stopHTTP terminates the HTTP RPC endpoint. // stopHTTP terminates the HTTP RPC endpoint.
func (n *Node) stopHTTP() { func (n *Node) stopHTTP() {
if n.httpListener != nil { if n.httpListener != nil {