xmlrpc

package
v0.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2021 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Overview

Package xmlrpc provide an implementation of XML-RPC specification, http://xmlrpc.com/spec.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client for XML-RPC.

func NewClient

func NewClient(url *url.URL, timeout time.Duration) (client *Client, err error)

NewClient create and initialize new connection to RPC server.

func (*Client) Close

func (cl *Client) Close() (err error)

Close the client connection.

func (*Client) Send

func (cl *Client) Send(req Request) (resp Response, err error)

Send the RPC method with parameters to the server.

type Kind

type Kind int

Kind define the known type in Value.

This is looks like the reflect.Kind but limited only to specific types defined in XML-RPC.

const (
	Unset    Kind = iota
	String        // represent Go string type.
	Boolean       // represent Go bool type.
	Integer       // represent Go int8, int16, int32, uint8, and uint16 types.
	Double        // represent Go uint32, uint64, float32, and float64 types.
	DateTime      // represent Go time.Time type.
	Base64        // represent Go string type.
	Struct        // represent Go struct type.
	Array         // represent Go array and slice types.
)

type Request

type Request struct {
	MethodName string
	Params     []*Value
}

Request represent the XML-RPC request, including method name and optional parameters.

func NewRequest

func NewRequest(methodName string, params []interface{}) (req Request, err error)

NewRequest create and initialize new request.

func (Request) MarshalText

func (req Request) MarshalText() (out []byte, err error)

MarshalText implement the encoding.TextMarshaler interface.

func (*Request) UnmarshalText added in v0.27.0

func (req *Request) UnmarshalText(text []byte) (err error)

UnmarshalText parse the XML request.

type Response

type Response struct {
	liberrors.E
	Param *Value
}

func (*Response) MarshalText added in v0.27.0

func (resp *Response) MarshalText() (out []byte, err error)

MarshalText encode the Response instance into XML text.

func (*Response) UnmarshalText

func (resp *Response) UnmarshalText(text []byte) (err error)

func (*Response) Unwrap added in v0.27.0

func (resp *Response) Unwrap() (err error)

Unwrap return the error as instance of *liberror.E.

type Value

type Value struct {
	Kind Kind
	// In contains scalar value for Base64, Boolean, Double, Integer,
	// String, and DateTime.
	// It would be nil for Kind of Array and Struct.
	In interface{}

	// Pair of struct member name and its value.
	StructMembers map[string]*Value

	// List of array values.
	ArrayValues []*Value
}

Value represent dynamic value of XML-RPC type.

func NewValue

func NewValue(in interface{}) (out *Value)

NewValue convert Go type data into XML-RPC value.

func (*Value) GetFieldAsFloat

func (v *Value) GetFieldAsFloat(key string) float64

GetFieldAsFloat get struct's field value by name as float64.

func (*Value) GetFieldAsInteger

func (v *Value) GetFieldAsInteger(key string) int

GetFieldAsInteger get struct's field value by name as int.

func (*Value) GetFieldAsString

func (v *Value) GetFieldAsString(key string) string

GetFieldAsString get struct's field value by name as string.

func (*Value) String

func (v *Value) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL