rpcsrv

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPPath = "/http"
	WSPath   = "/ws"
)

URL paths.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr           string
	AllowedOrigins []string
	TLS            *TLSConfig
}

Config is a RPC server configuration.

func NewConfig

func NewConfig() *Config

NewConfig creates a new configuration.

type Error

type Error struct {
	Code    int    `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
}

Error is an error to be passed within RPC notification. Regular errors cannot be properly marshaled into JSON, so they should be converted into Error pointers before being sent.

func ToError

func ToError(err error) *Error

ToError converts error into Error pointer.

func (*Error) Error

func (e *Error) Error() string

Error returns an error message of a given error.

func (*Error) ErrorCode

func (e *Error) ErrorCode() int

ErrorCode returns an error code of a given error.

type Server

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

Server is a RPC server which supports both HTTP and WS.

func NewServer

func NewServer(conf *Config) (*Server, error)

NewServer creates a new UI server.

func (*Server) AddHandler

func (s *Server) AddHandler(namespace string, handler interface{}) error

AddHandler registers a new RPC handler in a given namespace.

func (*Server) Close

func (s *Server) Close() error

Close immediately closes the server making ListenAndServe() to return.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe starts to listen and to serve requests.

type TLSConfig

type TLSConfig struct {
	CertFile string
	KeyFile  string
}

TLSConfig is a TLS configuration.

Jump to

Keyboard shortcuts

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