luxwsclient

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String(s string) *string

String stores s in a new string value and returns a pointer to it.

Types

type Client

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

Client is a wrapper around an underlying LuxWS connection.

func Dial

func Dial(ctx context.Context, address string, opts ...Option) (*Client, error)

Dial connects to a LuxWS server. The address must have the format "<host>:<port>" (see net.JoinHostPort). Use the context to establish a timeout.

IDs returned by the server are unique to each connection.

func (*Client) Close

func (c *Client) Close() error

Close closes the underlying network connection.

func (*Client) Get

func (c *Client) Get(ctx context.Context, id string) (*ContentRoot, error)

Get sends a "GET" command. The page content is returned.

func (*Client) Login

func (c *Client) Login(ctx context.Context, password string) (*NavRoot, error)

Login sends a "LOGIN" command. The navigation structure is returned.

type ContentItem

type ContentItem struct {
	ID      string              `xml:"id,attr"`
	Name    string              `xml:"name"`
	Min     *string             `xml:"min"`
	Max     *string             `xml:"max"`
	Step    *string             `xml:"step"`
	Unit    *string             `xml:"unit"`
	Div     *string             `xml:"div"`
	Raw     *string             `xml:"raw"`
	Value   *string             `xml:"value"`
	Columns []string            `xml:"columns"`
	Headers []string            `xml:"headers"`
	Options []ContentItemOption `xml:"option"`
	Items   []ContentItem       `xml:"item"`
}

ContentItem is an individual entry on a content page.

type ContentItemOption

type ContentItemOption struct {
	Value string `xml:"value,attr"`
	Name  string `xml:",chardata"`
}

ContentItemOption represents one option among others of a content item.

type ContentRoot

type ContentRoot struct {
	XMLName xml.Name
	Items   []ContentItem `xml:"item"`
}

ContentRoot contains all items returned by a GET request to a LuxWS server.

func (*ContentRoot) FindByName

func (r *ContentRoot) FindByName(name string) *ContentItem

FindByName iterates through all items and finds the first with a given name. Returns nil if none is found.

type LogFunc added in v0.3.0

type LogFunc func(format string, v ...any)

LogFunc describes a logging function (e.g. log.Printf).

type NavItem struct {
	ID    string    `xml:"id,attr"`
	Name  string    `xml:"name"`
	Items []NavItem `xml:"item"`
}

NavItem is an individual entry in the navigation structure.

type NavRoot struct {
	XMLName xml.Name
	ID      string    `xml:"id,attr"`
	Items   []NavItem `xml:"item"`
}

NavRoot represents the navigation structure of a LuxWS server.

func (r *NavRoot) FindByName(name string) *NavItem

FindByName iterates through all items and finds the first with a given name. Returns nil if none is found.

type Option added in v0.3.0

type Option func(*Client)

Option is the type of options for clients.

func WithLogFunc added in v0.3.0

func WithLogFunc(logf LogFunc) Option

WithLogFunc supplies a logging function to the client.

Jump to

Keyboard shortcuts

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