Documentation ¶
Overview ¶
Package xmlrpc includes everything that is required to perform XML-RPC requests by utilizing familiar rpc.Client interface.
The simplest use-case is creating a client towards an endpoint and making calls:
c, _ := NewClient("https://bugzilla.mozilla.org/xmlrpc.cgi") resp := &struct { BugzillaVersion struct { Version string } }{} err = c.Call("Bugzilla.version", nil, resp) fmt.Printf("Version: %s\n", resp.BugzillaVersion.Version)
Index ¶
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 ¶
func NewCustomClient(endpoint string, httpClient *http.Client, headers map[string]string) (*Client, error)
NewCustomClient allows customization of http.Client and headers used to make RPC calls. If provided endpoint is not valid, an error is returned.
func (*Client) SetUserAgent ¶
SetUserAgent allows customization to User-Agent header. If set to an empty string, User-Agent header will be sent with an empty value.
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 ¶
type Decoder ¶
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 ¶
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 Response ¶
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 ¶
NewResponse creates a Response object from XML body. It relies on XML Unmarshaler and if it fails - error is returned.
type ResponseFault ¶
type ResponseFault struct {
Value ResponseValue `xml:"value"`
}
type ResponseParam ¶
type ResponseParam struct {
Value ResponseValue `xml:"value"`
}
type ResponseStructMember ¶
type ResponseStructMember struct { Name string `xml:"name"` Value ResponseValue `xml:"value"` }
type ResponseValue ¶
type ResponseValue struct { Array []*ResponseValue `xml:"array>data>value"` 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"` }
type StdDecoder ¶
type StdDecoder struct{}
StdDecoder is the default implementation of the Decoder interface.
func (*StdDecoder) Decode ¶
func (d *StdDecoder) Decode(response *Response, v interface{}) error
func (*StdDecoder) DecodeFault ¶
func (d *StdDecoder) DecodeFault(response *Response) *Fault
func (*StdDecoder) DecodeRaw ¶
func (d *StdDecoder) DecodeRaw(body []byte, v interface{}) error
type StdEncoder ¶
type StdEncoder struct{}
StdEncoder is the default implementation of Encoder interface.