-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move jsonrpc changes of proxy to cache package
- Loading branch information
Showing
9 changed files
with
73 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package json_rpc_cache | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
type jsonRpcReq struct { | ||
ID json.RawMessage `json:"id"` | ||
Method string `json:"method"` | ||
Params json.RawMessage `json:"params"` | ||
} | ||
|
||
type jsonRpcResp struct { | ||
ID json.RawMessage `json:"id"` | ||
Result json.RawMessage `json:"result"` | ||
Error *jsonRpcError `json:"error"` | ||
} | ||
|
||
type errorResponse struct { | ||
JSONRPC string `json:"jsonrpc"` | ||
ID json.RawMessage `json:"id"` | ||
Error jsonRpcError `json:"error"` | ||
} | ||
|
||
type jsonRpcError struct { | ||
Code int `json:"code"` | ||
Message string `json:"message"` | ||
} | ||
|
||
func decodeBody(req *http.Request) (*jsonRpcReq, error) { | ||
var decodedBody jsonRpcReq | ||
if err := json.NewDecoder(req.Body).Decode(&decodedBody); err != nil { | ||
return nil, fmt.Errorf("failed to decode json-rpc request body") | ||
} | ||
return &decodedBody, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters