rpc

package
v0.0.0-...-75c22fc Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: MIT Imports: 15 Imported by: 0

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) 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 Request

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

Request for XML RPCs

func ParseRequest

func ParseRequest(reader io.Reader) (*Request, error)

ParseRequest from XML

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 ParseResponse

func ParseResponse(reader io.Reader) (*Response, error)

ParseResponse from XML

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