Documentation
¶
Index ¶
- type GeneralData
- type OptionRestHandler
- func WithEndpoint(endpoint string) OptionRestHandler
- func WithPort(port int) OptionRestHandler
- func WithProxyHost(host string) OptionRestHandler
- func WithProxyPassword(password string) OptionRestHandler
- func WithProxyPort(port int) OptionRestHandler
- func WithProxyProtocol(protocol Protocol) OptionRestHandler
- func WithProxyScheme(scheme Scheme) OptionRestHandler
- func WithProxyUsername(username string) OptionRestHandler
- func WithScheme(scheme Scheme) OptionRestHandler
- type Protocol
- type RestHandler
- type Scheme
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 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 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)