xmlrpc

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Data []*Value `xml:"data>value"`
}

Array represents an XML-RPC array.

type BasicDispatcher added in v0.2.2

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

BasicDispatcher dispatches an XML-RPC call to a registered function.

func (*BasicDispatcher) AddSystemMethods added in v0.2.2

func (d *BasicDispatcher) AddSystemMethods()

AddSystemMethods adds system.multicall and system.listMethods.

func (*BasicDispatcher) Dispatch added in v0.2.2

func (d *BasicDispatcher) Dispatch(methodName string, args *Value) (*Value, error)

Dispatch dispatches a method call to a registered function.

func (*BasicDispatcher) Handle added in v0.2.2

func (d *BasicDispatcher) Handle(name string, m Method)

Handle registers a Method.

func (*BasicDispatcher) HandleFunc added in v0.2.2

func (d *BasicDispatcher) HandleFunc(name string, f func(*Value) (*Value, error))

HandleFunc registers an ordinary function as Method.

func (*BasicDispatcher) HandleUnknownFunc added in v0.2.2

func (d *BasicDispatcher) HandleUnknownFunc(f func(string, *Value) (*Value, error))

HandleUnknownFunc registers an ordinary function to handle unknown methods names.

type Caller added in v0.1.2

type Caller interface {
	Call(method string, params Values) (*Value, error)
}

Caller is an interface for calling XML-RPC functions.

type Client

type Client struct {
	Addr              string
	ResponseSizeLimit int64
}

Client provides access to an XML-RPC server.

func (*Client) Call

func (c *Client) Call(method string, params Values) (*Value, error)

Call executes an remote procedure call. Call implements Caller.

type Dispatcher added in v0.1.2

type Dispatcher interface {
	AddSystemMethods()
	Handle(name string, m Method)
	HandleFunc(name string, f func(*Value) (*Value, error))
	HandleUnknownFunc(f func(string, *Value) (*Value, error))
	Dispatch(methodName string, args *Value) (*Value, error)
}

Dispatcher dispatches a received XML-RPC call to registered handlers.

type Handler

type Handler struct {
	RequestSizeLimit int64
	Dispatcher
}

Handler implements a http.Handler which can handle XML-RPC requests. Remote calls are dispatched to the registered Method's.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type Member

type Member struct {
	Name  string `xml:"name"`
	Value *Value
}

Member represents an XML-RPC struct member.

type Method

type Method interface {
	Call(*Value) (*Value, error)
}

A Method is dispatched from a Handler. The argument contains always an array.

type MethodCall

type MethodCall struct {
	MethodName string   `xml:"methodName"`
	Params     *Params  `xml:"params"`
	XMLName    xml.Name `xml:"methodCall"`
}

MethodCall represents an XML-RPC method call.

type MethodError

type MethodError struct {
	Code    int
	Message string
}

MethodError encapsulates an XML-RPC fault response.

func (*MethodError) Error

func (f *MethodError) Error() string

Error implements the error interface.

type MethodFunc

type MethodFunc func(*Value) (*Value, error)

MethodFunc is an adapter to use ordinary functions as Method's.

func (MethodFunc) Call

func (m MethodFunc) Call(args *Value) (*Value, error)

Call implements interface Method.

type MethodResponse

type MethodResponse struct {
	Params  *Params  `xml:"params"`
	Fault   *Value   `xml:"fault>value"`
	XMLName xml.Name `xml:"methodResponse"`
}

MethodResponse represents an XML-RPC method response.

type Param

type Param struct {
	Value *Value
}

Param is a single parameter.

type Params

type Params struct {
	Param []*Param `xml:"param"`
}

Params holds the parameters for the method call or response.

type Query

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

Query helps to extract values from the XML model.

func Q

func Q(v *Value) *Query

Q creates a new Query for the specified Value.

func (*Query) Any

func (q *Query) Any() interface{}

Any returns data type int, bool, float64, string or nil for an empty optional. For Struct or Array an error is set.

func (*Query) Bool

func (q *Query) Bool() bool

Bool gets an XML-RPC boolean value.

func (*Query) Err

func (q *Query) Err() error

Err returns the first encountered error.

func (*Query) Float64

func (q *Query) Float64() float64

Float64 gets an XML-RPC double value.

func (*Query) Idx

func (q *Query) Idx(i int) *Query

Idx returns the array element at i.

func (*Query) Int

func (q *Query) Int() (i int)

Int gets an XML-RPC int or i4 value.

func (*Query) IsEmpty

func (q *Query) IsEmpty() bool

IsEmpty returns true, if there is no previous error and the value is empty. An empty value can also be interpreted as an empty string.

func (*Query) IsNotEmpty

func (q *Query) IsNotEmpty() bool

IsNotEmpty returns true, if there is no previous error and the value is not empty. An empty value can also be interpreted as an empty string.

func (*Query) Key

func (q *Query) Key(name string) *Query

Key sets an error, if the specified member is missing.

func (*Query) Map

func (q *Query) Map() map[string]*Query

Map returns all members of an XML-RPC struct.

func (*Query) Slice

func (q *Query) Slice() []*Query

Slice returns all array elements.

func (*Query) String

func (q *Query) String() string

String gets an XML-RPC string value.

func (*Query) Strings

func (q *Query) Strings() []string

Strings returns a string array.

func (*Query) TryKey

func (q *Query) TryKey(name string) *Query

TryKey does not set an error, if the specified member is missing.

func (*Query) Value

func (q *Query) Value() *Value

Value returns the wrapped Value.

type RetryingCaller added in v1.2.0

type RetryingCaller struct {
	// Function that is called multiple times if it returns an error.
	Caller Caller

	// Number of retries. 0 disables retries.
	RetryCount int

	// Delay between retries.
	RetryDelay time.Duration

	// The repeated calls can be cancelled with this context.
	Context conc.Context
}

func (*RetryingCaller) Call added in v1.2.0

func (c *RetryingCaller) Call(method string, params Values) (*Value, error)

type Struct

type Struct struct {
	Members []*Member `xml:"member"`
}

Struct represents an XML-RPC struct.

type Value

type Value struct {
	I4         string   `xml:"i4,omitempty"`
	Int        string   `xml:"int,omitempty"`
	Boolean    string   `xml:"boolean,omitempty"`
	ElemString string   `xml:"string,omitempty"`
	FlatString string   `xml:",chardata"`
	Double     string   `xml:"double,omitempty"`
	DateTime   string   `xml:"dateTime.iso8601,omitempty"`
	Base64     string   `xml:"base64,omitempty"`
	Struct     *Struct  `xml:"struct"`
	Array      *Array   `xml:"array"`
	XMLName    xml.Name `xml:"value"`
}

Value represents an XML-RPC value.

func NewBool added in v0.3.0

func NewBool(val bool) *Value

NewBool creates an xmlrpc.Value from a bool.

func NewFloat64 added in v0.3.0

func NewFloat64(val float64) *Value

NewFloat64 creates an xmlrpc.Value from a float64.

func NewInt added in v0.3.0

func NewInt(val int) *Value

NewInt creates an xmlrpc.Value from an int.

func NewMap added in v0.3.0

func NewMap(val map[string]interface{}) (*Value, error)

NewMap creates an xmlrpc.Value from a map.

func NewSlice added in v0.3.0

func NewSlice(val []interface{}) (*Value, error)

NewSlice creates an xmlrpc.Value from a slice.

func NewString added in v0.3.0

func NewString(val string) *Value

NewString creates an xmlrpc.Value from a string.

func NewStrings added in v0.3.0

func NewStrings(val []string) *Value

NewStrings creates an xmlrpc.Value from a string slice.

func NewValue

func NewValue(in interface{}) (*Value, error)

NewValue creates a value from a native data type. Supported types: bool, int, float64, string, []string, []interface{} and map[string]interface{}.

func (*Value) String

func (v *Value) String() string

String implements the Stringer interface. Data types are indicated by the representation.

type Values added in v0.2.0

type Values []*Value

Values is a slice of Value's. The type is used by the Caller interface.

func (Values) String added in v0.2.0

func (vs Values) String() string

String implements the Stringer interface.

Jump to

Keyboard shortcuts

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