Documentation
¶
Index ¶
- type Client
- type Codec
- func (c *Codec) Close() error
- func (c *Codec) ReadResponseBody(v interface{}) error
- func (c *Codec) ReadResponseHeader(resp *rpc.Response) error
- func (c *Codec) SetDecoder(decoder Decoder)
- func (c *Codec) SetEncoder(encoder Encoder)
- func (c *Codec) WriteRequest(req *rpc.Request, args interface{}) error
- type Decoder
- type Encoder
- type Fault
- type Option
- type Response
- type ResponseArrayData
- type ResponseFault
- type ResponseParam
- type ResponseStructMember
- type ResponseValue
- type StdDecoder
- type StdEncoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client is responsible for making calls to RPC services with help of underlying rpc.Client.
func NewClient ¶
NewClient creates a Client with http.DefaultClient. If provided endpoint is not valid, an error is returned.
func NewCustomClient ¶ added in v0.2.0
NewCustomClient allows customization of http.Client used to make RPC calls. If provided endpoint is not valid, an error is returned. Deprecated: prefer using NewClient with HttpClient Option
type Codec ¶
type Codec struct {
// contains filtered or unexported fields
}
Codec implements methods required by rpc.ClientCodec In this implementation Codec is the one performing actual RPC requests with http.Client.
func NewCodec ¶
NewCodec creates a new Codec bound to provided endpoint. Provided client will be used to perform RPC requests.
func (*Codec) ReadResponseBody ¶
func (*Codec) SetDecoder ¶ added in v0.4.0
SetDecoder allows setting a new Decoder on the codec
func (*Codec) SetEncoder ¶ added in v0.4.0
SetEncoder allows setting a new Encoder on the codec
type Decoder ¶ added in v0.1.1
type Decoder interface { DecodeRaw(body []byte, v interface{}) error Decode(response *Response, v interface{}) error DecodeFault(response *Response) *Fault }
Decoder implementations provide mechanisms for parsing of XML-RPC responses to native data-types.
type Encoder ¶ added in v0.1.1
Encoder implementations are responsible for handling encoding of XML-RPC requests to the proper wire format.
type Fault ¶
type Fault struct { // Code provides numerical failure code Code int // String includes more detailed information about the fault, such as error name and cause String string }
Fault is a wrapper for XML-RPC fault object
type Option ¶ added in v0.2.0
type Option func(client *Client)
Option is a function that configures a Client by mutating it
func Headers ¶ added in v0.2.0
Headers option allows setting custom headers that will be passed with every request
func HttpClient ¶ added in v0.2.0
HttpClient option allows setting custom HTTP Client to be used for every request
func SkipUnknownFields ¶ added in v0.4.0
SkipUnknownFields option allows setting decoder setting to skip unknown fields. This is only effective if using standard client, which in turn uses StdDecoder.
type Response ¶ added in v0.1.1
type Response struct { Params []*ResponseParam `xml:"params>param"` Fault *ResponseFault `xml:"fault,omitempty"` }
Response is the basic parsed object of the XML-RPC response body. While it's not convenient to use this object directly - it contains all the information needed to unmarshal into other data-types.
func NewResponse ¶ added in v0.1.1
NewResponse creates a Response object from XML body. It relies on XML Unmarshaler and if it fails - error is returned.
type ResponseArrayData ¶ added in v0.5.1
type ResponseArrayData struct {
Values []*ResponseValue `xml:"value"`
}
ResponseArrayData contains a list of array values
type ResponseFault ¶ added in v0.1.1
type ResponseFault struct {
Value ResponseValue `xml:"value"`
}
ResponseFault wraps around failure
type ResponseParam ¶ added in v0.1.1
type ResponseParam struct {
Value ResponseValue `xml:"value"`
}
ResponseParam encapsulates a nested parameter value
type ResponseStructMember ¶ added in v0.1.1
type ResponseStructMember struct { Name string `xml:"name"` Value ResponseValue `xml:"value"` }
ResponseStructMember contains name-value pair of the struct
type ResponseValue ¶ added in v0.1.1
type ResponseValue struct { Array *ResponseArrayData `xml:"array>data"` Struct []*ResponseStructMember `xml:"struct>member"` String *string `xml:"string"` Int *string `xml:"int"` Int4 *string `xml:"i4"` Double *string `xml:"double"` Boolean *string `xml:"boolean"` DateTime *string `xml:"dateTime.iso8601"` Base64 *string `xml:"base64"` RawXML string `xml:",innerxml"` }
ResponseValue encapsulates one of the data types for each parameter. Only one field should be set.
type StdDecoder ¶ added in v0.1.1
type StdDecoder struct {
// contains filtered or unexported fields
}
StdDecoder is the default implementation of the Decoder interface.
func (*StdDecoder) Decode ¶ added in v0.1.1
func (d *StdDecoder) Decode(response *Response, v interface{}) error
func (*StdDecoder) DecodeFault ¶ added in v0.1.1
func (d *StdDecoder) DecodeFault(response *Response) *Fault
func (*StdDecoder) DecodeRaw ¶ added in v0.1.1
func (d *StdDecoder) DecodeRaw(body []byte, v interface{}) error
type StdEncoder ¶ added in v0.1.1
type StdEncoder struct{}
StdEncoder is the default implementation of Encoder interface.