Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandler ¶
HTTPHandler returns handler for HTTP requests which will execute incoming JSON-RPC 2.0 over HTTP using srv.
If srv is nil then rpc.DefaultServer will be used.
Specification: http://www.simple-is-better.org/json-rpc/transport_http.html
func HTTPRequestFromContext ¶
HTTPRequestFromContext returns HTTP request related to this RPC (if you use HTTPHander to serve JSON RPC 2.0 over HTTP) or nil otherwise.
func NewClientCodec ¶
func NewClientCodec(conn io.ReadWriteCloser) rpc.ClientCodec
NewClientCodec returns a new rpc.ClientCodec using JSON-RPC 2.0 on conn.
Types ¶
type Client ¶
Client represents a JSON RPC 2.0 Client. There may be multiple outstanding Calls associated with a single Client, and a Client may be used by multiple goroutines simultaneously.
It also provides all methods of net/rpc Client.
func NewClient ¶
func NewClient(conn io.ReadWriteCloser) *Client
NewClient returns a new Client to handle requests to the set of services at the other end of the connection.
func NewClientWithCodec ¶
func NewClientWithCodec(codec rpc.ClientCodec) *Client
NewClientWithCodec returns a new Client using the given rpc.ClientCodec.
func NewCustomHTTPClient ¶
NewCustomHTTPClient returns a new Client to handle requests to the set of services at the given url using provided doer (&http.Client{} by default).
Use doer to customize HTTP authorization/headers/etc. sent with each request (it method Do() will receive already configured POST request with url, all required headers and body set according to specification).
func NewHTTPClient ¶
NewHTTPClient returns a new Client to handle requests to the set of services at the given url.
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
Ctx can be embedded into your struct with RPC method parameters (if that method parameters type is a struct) to make it implement WithContext interface and thus have access to request context.
func (*Ctx) SetContext ¶
SetContext saves ctx for succeeding Context calls.
type DoerFunc ¶
The DoerFunc type is an adapter to allow the use of ordinary functions as HTTP clients. If f is a function with the appropriate signature, DoerFunc(f) is a client that calls f.
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.
type WithContext ¶
WithContext is an interface which should be implemented by RPC method parameters type if you need access to request context in RPC method.
Request context will be same as was provided to corresponding ServeConnContext/NewServerCodecContext or context.Background otherwise.