modulepackage
0.0.0-20170418060308-ff2654212329
Repository: https://github.com/teambition/jsonrpc-go.git
Documentation: pkg.go.dev
# README
jsonrpc
jsonrpc is an golang implementation just for parse and serialize JSON-RPC2 messages, it's easy to integration with your any application.
Inspired by https://github.com/teambition/jsonrpc-lite and JSON-RPC 2.0 specifications
Installation
go get github.com/teambition/jsonrpc-go
API
Generate jsonrpc 2.0 message.
// Request creates a JSON-RPC 2.0 request message structures.
// the id must be {String|Integer|nil} type
func Request(id interface{}, method string, args ...interface{}) (result []byte, err *ErrorObj)
// Notification Creates a JSON-RPC 2.0 notification message structures without id.
func Notification(method string, args ...interface{}) ([]byte, *ErrorObj)
//Batch return a JSON-RPC 2.0 batch message structures.
func Batch(batch ...string) (arrstr []byte)
// Success return a JSON-RPC 2.0 success message structures.
// The result parameter is required
func Success(id interface{}, msg interface{}) (result []byte, err *ErrorObj)
//Error return a JSON-RPC 2.0 error message structures.
func Error(id interface{}, rpcerr *ErrorObj) (result []byte, err *ErrorObj)
Parse jsonrpc 2.0 message structures.
// Parse return jsonrpc 2.0 single or batch message object that depend on you msg type.
func Parse(msg []byte) (req *RPC, batch []*RPC)
// Parse string return jsonrpc 2.0 single or batch message object that depend on you msg type.
func ParseString(msg string) (req *RPC, batch []*RPC)
# Packages
No description provided by the author
# Functions
Batch return a JSON-RPC 2.0 batch message structures.
Error return a JSON-RPC 2.0 error message structures.
ErrorFrom return an ErrorObj by native error.
ErrorWith return an ErrorObj by arguments.
InternalError Internal JSON-RPC error.
InvalidParams Invalid method parameter(s).
InvalidRequest the request is not a valid Request object.
MethodNotFound the method does not exist or is not available.
Notification return a JSON-RPC 2.0 notification message structures without id.
Parse return jsonrpc 2.0 message object, ignore the first return value if the msg is batch rpc.
ParseError invalid JSON was received by the server.An error occurred on the server while parsing the JSON text.
ParseString ...
Request return a JSON-RPC 2.0 request message structures.
Success return a JSON-RPC 2.0 success message structures.
# Constants
ErrorType Error message type.
InvalidType Invalid message type.
NotificationType Notification message type.
RequestType Request message type.
SuccessType Success message type.
# Type aliases
MsgType ...