Skip to content
Snippets Groups Projects
Unverified Commit 5377dcd0 authored by Benjamin Bollen's avatar Benjamin Bollen
Browse files

rpc: add AssertIsRPCResponse as marker method for restricting implementation...

rpc: add AssertIsRPCResponse as marker method for restricting implementation of interface to actual RPCResponse types
parent 892ceb5b
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,9 @@ type ( ...@@ -40,7 +40,9 @@ type (
// RPCResponse MUST follow the JSON-RPC specification for Response object // RPCResponse MUST follow the JSON-RPC specification for Response object
// reference: http://www.jsonrpc.org/specification#response_object // reference: http://www.jsonrpc.org/specification#response_object
RPCResponse interface{} RPCResponse interface {
AssertIsRPCResponse() bool
}
// RPCResultResponse MUST NOT contain the error member if no error occurred // RPCResultResponse MUST NOT contain the error member if no error occurred
RPCResultResponse struct { RPCResultResponse struct {
...@@ -82,3 +84,15 @@ func NewRPCErrorResponse(id string, code int, message string) RPCResponse { ...@@ -82,3 +84,15 @@ func NewRPCErrorResponse(id string, code int, message string) RPCResponse {
JSONRPC: "2.0", JSONRPC: "2.0",
}) })
} }
// AssertIsRPCResponse implements a marker method for RPCResultResponse
// to implement the interface RPCResponse
func (rpcResultResponse *RPCResultResponse) AssertIsRPCResponse() bool {
return true
}
// AssertIsRPCResponse implements a marker method for RPCErrorResponse
// to implement the interface RPCResponse
func (rpcErrorResponse *RPCErrorResponse) AssertIsRPCResponse() bool {
return true
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment