README ¶
JSON-RPC 2.0 Codec
Usage
Import the codec and set within the client/server
package main
import (
"github.com/micro/go-micro"
"github.com/micro/go-micro/client"
"github.com/micro/go-micro/server"
"github.com/micro/go-plugins/codec/jsonrpc2"
)
func main() {
client := client.NewClient(
client.Codec("application/json", jsonrpc2.NewCodec),
client.ContentType("application/json"),
)
server := server.NewServer(
server.Codec("application/json", jsonrpc2.NewCodec),
)
service := micro.NewService(
micro.Client(client),
micro.Server(server),
)
// ...
}
Documentation ¶
Overview ¶
Package jsonrpc2 provides a json-rpc 2.0 codec
Based on powerman/rpc-codec: The MIT License (MIT) Copyright (c) 2015 Alex Efros
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Error ¶
type Error struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` }
Error represent JSON-RPC 2.0 "Error object".
func ServerError ¶
ServerError convert errors returned by Client.Call() into Error. User should check for rpc.ErrShutdown and io.ErrUnexpectedEOF before calling ServerError.
Click to show internal directories.
Click to hide internal directories.