Skip to content

Commit

Permalink
Rename api var for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
tgerring committed Jan 27, 2015
1 parent d8c6168 commit e9d017b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions rpc/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (s *RpcHttpServer) Start() {
}
}

func (s *RpcHttpServer) apiHandler(xeth *rpc.EthereumApi) http.Handler {
func (s *RpcHttpServer) apiHandler(api *rpc.EthereumApi) http.Handler {
fn := func(w http.ResponseWriter, req *http.Request) {
rpchttplogger.Debugln("Handling request")

Expand All @@ -94,7 +94,7 @@ func (s *RpcHttpServer) apiHandler(xeth *rpc.EthereumApi) http.Handler {
}

var response interface{}
reserr := xeth.GetRequestReply(&reqParsed, &response)
reserr := api.GetRequestReply(&reqParsed, &response)
if reserr != nil {
rpchttplogger.Errorln(reserr)
JSON.Send(w, &rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()})
Expand Down
9 changes: 4 additions & 5 deletions rpc/ws/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,19 @@ func (self *WebSocketServer) Start() {
}
}

func (s *WebSocketServer) apiHandler(xeth *rpc.EthereumApi) http.Handler {
func (s *WebSocketServer) apiHandler(api *rpc.EthereumApi) http.Handler {
fn := func(w http.ResponseWriter, req *http.Request) {
h := sockHandler(xeth)
h := sockHandler(api)
s := websocket.Server{Handler: h}
s.ServeHTTP(w, req)
}

return http.HandlerFunc(fn)
}

func sockHandler(xeth *rpc.EthereumApi) websocket.Handler {
func sockHandler(api *rpc.EthereumApi) websocket.Handler {
fn := func(conn *websocket.Conn) {
for {
// FIX wslogger does not output to console
wslogger.Debugln("Handling request")
var reqParsed rpc.RpcRequest

Expand All @@ -109,7 +108,7 @@ func sockHandler(xeth *rpc.EthereumApi) websocket.Handler {
}

var response interface{}
reserr := xeth.GetRequestReply(&reqParsed, &response)
reserr := api.GetRequestReply(&reqParsed, &response)
if reserr != nil {
wslogger.Errorln(reserr)
websocket.JSON.Send(conn, rpc.RpcErrorResponse{JsonRpc: reqParsed.JsonRpc, ID: reqParsed.ID, Error: true, ErrorText: reserr.Error()})
Expand Down

0 comments on commit e9d017b

Please sign in to comment.