diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-01-26 04:50:43 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-01-28 02:29:07 +0800 |
commit | d790229a33b1f3e6256ca6916be17a0cc3663076 (patch) | |
tree | 66351ba83d698b077a29f7374f6805b9ecfcda66 /rpc/json.go | |
parent | 7a894e37388fccef1fa7945bb20b7cf8f0c1ce3c (diff) | |
download | go-tangerine-d790229a33b1f3e6256ca6916be17a0cc3663076.tar go-tangerine-d790229a33b1f3e6256ca6916be17a0cc3663076.tar.gz go-tangerine-d790229a33b1f3e6256ca6916be17a0cc3663076.tar.bz2 go-tangerine-d790229a33b1f3e6256ca6916be17a0cc3663076.tar.lz go-tangerine-d790229a33b1f3e6256ca6916be17a0cc3663076.tar.xz go-tangerine-d790229a33b1f3e6256ca6916be17a0cc3663076.tar.zst go-tangerine-d790229a33b1f3e6256ca6916be17a0cc3663076.zip |
Move HTTP transport to sub package of RPC
Diffstat (limited to 'rpc/json.go')
-rw-r--r-- | rpc/json.go | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/rpc/json.go b/rpc/json.go index 5446cb3c1..9bd204818 100644 --- a/rpc/json.go +++ b/rpc/json.go @@ -18,25 +18,28 @@ package rpc import ( "encoding/json" + "github.com/ethereum/go-ethereum/logger" "io" "net/http" ) -type jsonWrapper struct{} +var rpclogger = logger.NewLogger("RPC") -func (self jsonWrapper) Send(writer io.Writer, v interface{}) (n int, err error) { +type JsonWrapper struct{} + +func (self JsonWrapper) Send(writer io.Writer, v interface{}) (n int, err error) { var payload []byte payload, err = json.Marshal(v) if err != nil { - jsonlogger.Fatalln("Error marshalling JSON", err) + rpclogger.Fatalln("Error marshalling JSON", err) return 0, err } - jsonlogger.Infof("Sending payload: %s", payload) + rpclogger.Infof("Sending payload: %s", payload) return writer.Write(payload) } -func (self jsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error) { +func (self JsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error) { var reqParsed RpcRequest // Convert JSON to native types @@ -46,12 +49,10 @@ func (self jsonWrapper) ParseRequestBody(req *http.Request) (RpcRequest, error) err := d.Decode(&reqParsed) if err != nil { - jsonlogger.Errorln("Error decoding JSON: ", err) + rpclogger.Errorln("Error decoding JSON: ", err) return reqParsed, err } - jsonlogger.DebugDetailf("Parsed request: %s", reqParsed) + rpclogger.DebugDetailf("Parsed request: %s", reqParsed) return reqParsed, nil } - -var JSON jsonWrapper |