xmlrpc

package module
v0.0.0-...-792c0c2 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

README

XML-RPC Library

godoc

This is a simple XML-RPC client implementation. There is also a basic server part that can be used for callbacks.

Usage

Import via

gitlab.com/bboehmke/go-xmlrpc

then create a client and do a RPC call to a server:

// create client
client, err := xmlrpc.NewClient("https://mxl-rpc.server")

// send request
response, err := client.Call("system.listMethods")

For the detailed usage see the API doc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Call(method string, params ...interface{}) (*Response, error)
	LocalIP() (string, error)
}

Client interface for XML RPC client

func NewClient

func NewClient(url string, opts ...Option) Client

NewClient creates new client

type Fault

type Fault struct {
	Code   int32
	String string
}

Fault information of response

type Handler

type Handler func(method string, params []interface{}) ([]interface{}, *Fault)

Handler for received RPC request

type Option

type Option func(client *client)

Option defines a function that configures a Client by mutating it

func HttpClient

func HttpClient(httpClient *http.Client) Option

HttpClient option allows setting custom HTTP Client

type Request

type Request struct {
	Method string
	Params []interface{}
}

Request for XML RPCs

func (Request) MarshalXML

func (r Request) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML convert request to XML

type Response

type Response struct {
	Params []interface{}
	Fault  *Fault
}

Response of XML RPCs

func (*Response) DecodeParam

func (r *Response) DecodeParam(idx int, val interface{}) error

DecodeParam to the given value

func (*Response) FirstParam

func (r *Response) FirstParam() interface{}

FirstParam returns the first parameter or nil

func (*Response) MarshalXML

func (r *Response) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML convert response to XML

type Server

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

Server for XML RPC events

func NewServer

func NewServer(handler Handler) (*Server, error)

NewServer creates new server

func (*Server) IsRunning

func (s *Server) IsRunning() bool

IsRunning returns true if server is running

func (*Server) Port

func (s *Server) Port() int

Port of http server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(writer http.ResponseWriter, request *http.Request)

ServeHTTP handles received requests

func (*Server) Start

func (s *Server) Start()

Start server

func (*Server) Stop

func (s *Server) Stop() error

Stop server

Jump to

Keyboard shortcuts

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