rest

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeneralData

type GeneralData struct {
	Cmd     string                     `json:"cmd"`
	Code    int                        `json:"code"`
	Value   map[string]json.RawMessage `json:"value,omitempty"`
	Initial map[string]json.RawMessage `json:"initial,omitempty"`
	Range   map[string]json.RawMessage `json:"range,omitempty"`
}

type OptionRestHandler

type OptionRestHandler interface {
	// contains filtered or unexported methods
}

func WithEndpoint

func WithEndpoint(endpoint string) OptionRestHandler

Change the default endpoint to a custom endpoint Default is "/cgi-bin/api.cgi" If for some reason the camera you are using is different, one can update it here.

func WithPort

func WithPort(port int) OptionRestHandler

Change the default port to a custom port. Default is unset due to http being the default protocol

func WithProxyHost

func WithProxyHost(host string) OptionRestHandler

Add a proxy host configuration

func WithProxyPassword

func WithProxyPassword(password string) OptionRestHandler

Add a password to the proxy configuration

func WithProxyPort

func WithProxyPort(port int) OptionRestHandler

Add a proxy port configuration

func WithProxyProtocol

func WithProxyProtocol(protocol Protocol) OptionRestHandler

func WithProxyScheme

func WithProxyScheme(scheme Scheme) OptionRestHandler

Change the default scheme from HTTP to HTTPS or SOCKS5

func WithProxyUsername

func WithProxyUsername(username string) OptionRestHandler

Add a username to the proxy configuration

func WithScheme

func WithScheme(scheme Scheme) OptionRestHandler

Change the default scheme from HTTP to HTTPS or SOCKS5

type Protocol

type Protocol uint
const (
	PROTOCOL_UDP Protocol = iota
	PROTOCOL_TCP
)

func (Protocol) String

func (p Protocol) String() string

type RestHandler

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

func NewRestHandler

func NewRestHandler(host string, opts ...OptionRestHandler) *RestHandler

Create a new RestHandler object with optional argument using Variadic options pattern for customisation Refer to the RestHandlerOption<option_name> functions RestHandler is used to wrap the http package and give a cleaner more defined scope which the person implementing the library will have full control over. https://stackoverflow.com/a/26326418

func (*RestHandler) GetToken

func (rh *RestHandler) GetToken() string

func (*RestHandler) Request

func (rh *RestHandler) Request(method string, payload interface{}, command string) (*GeneralData, error)

Do the http request endpoint: the trailing part of the URL after the port. method: GET or POST payload: the json data auth: alters the request to include auth token on true

func (*RestHandler) SetToken

func (rh *RestHandler) SetToken(token string)

type Scheme

type Scheme uint
const (
	HTTP Scheme = iota
	HTTPS
	SOCKS5
)

func (Scheme) String

func (p Scheme) String() string

Jump to

Keyboard shortcuts

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