Skip to content

An golang implementation for parse and serialize JSON-RPC2 messages

License

Notifications You must be signed in to change notification settings

Enghin84/jsonrpc-go

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonrpc

Build Status Coverage Status License GoDoc

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) 

About

An golang implementation for parse and serialize JSON-RPC2 messages

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%