api

package
v0.0.0-...-ba79be1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallMethod

func CallMethod(property string, params ...Param) http.Handler

CallMethod handles the requests that sets a given smart light property according to the given parameters. It's the caller's job to make sure they conform to the Yeelight API.

The bulb address is specified in the "bulb" query parameter.

func Config

func Config(config string) http.Handler

Config serves the config file.

func Get

func Get(h http.Handler) http.Handler

Get allows only HTTP GET requests.

func GetInfo

func GetInfo(requestedProps ...interface{}) http.Handler

GetInfo serves the info about the requested properties of a bulb.

The bulb address is specified in the "bulb" query parameter.

func Handle

func Handle(static fs.FS, config string)

Handle sets up all the HTTP handlers.

func HttpMethod

func HttpMethod(method string, h http.Handler) http.Handler

HttpMethod checks for the HTTP method of each handled request, rejecting all the other HTTP methods.

func Post

func Post(h http.Handler) http.Handler

Post allows only HTTP POST requests.

func PowerOn

func PowerOn(power bool) http.Handler

PowerOn turns the bulb on or off.

func SetBrightness

func SetBrightness() http.Handler

SetBrightness sets the brightness of a bulb.

func SetColor

func SetColor() http.Handler

SetColor sets the color of a bulb.

func SetTemperature

func SetTemperature() http.Handler

SetTemperature sets the color temperature of a bulb.

func Toggle

func Toggle() http.Handler

Toggle turns the bulb on and off

The bulb address is specified in the "bulb" query parameter.

func WithLogging

func WithLogging(h http.Handler) http.Handler

WithLogging logs the info about each handled request (but not response).

Types

type ConstParam

type ConstParam struct {
	Value interface{}
}

ConstParam has a constant value completely ignoring the HTTP request's contents.

func (ConstParam) Get

func (p ConstParam) Get(*http.Request) (interface{}, error)

type MapParam

type MapParam struct {
	Param
	// contains filtered or unexported fields
}

MapParam is a composite Param that maps the original Param's value through an arbitrary unary function.

func (MapParam) Get

func (p MapParam) Get(r *http.Request) (value interface{}, err error)

type NumParam

type NumParam struct {
	Param
	Base    int
	BitSize int
}

NumParam is a composite Param that converts the value of the original Param to a number.

func NewNumParam

func NewNumParam(p Param) NumParam

NewNumParam creates a NumParam with base 10.

func NewNumParamWithBase

func NewNumParamWithBase(p Param, base int) NumParam

NewNumParamWithBase creates a NumParam with a custom base.

func (NumParam) Get

func (p NumParam) Get(r *http.Request) (value interface{}, err error)

type Param

type Param interface {
	Get(r *http.Request) (interface{}, error)
}

Param is a parameter for the CallMethod calls, usually extracting some data from the associated HTTP request provided to the Get method.

type QueryParam

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

QueryParam extracts a value from the "param" query parameter.

func (QueryParam) Get

func (p QueryParam) Get(r *http.Request) (interface{}, error)

Jump to

Keyboard shortcuts

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