utils

package
v0.0.0-...-9604f65 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func APIDoc

func APIDoc(r *mux.Route, in, out interface{})

func AvgCpuLoad

func AvgCpuLoad() (*load.AvgStat, error)

func ErrorResponse

func ErrorResponse(header int, msg string, w http.ResponseWriter)

func FormatFloat

func FormatFloat(v float64) string

func GenerateCerts

func GenerateCerts() error

func JSONCreateResponse

func JSONCreateResponse(i interface{}, fn func() error, w http.ResponseWriter, r *http.Request)

func JSONDeleteResponse

func JSONDeleteResponse(fn func(string) error, w http.ResponseWriter, r *http.Request)

func JSONGetResponse

func JSONGetResponse(fn func(string) (interface{}, error), w http.ResponseWriter, r *http.Request)

func JSONGetUsage

func JSONGetUsage(usage Doer) http.HandlerFunc

func JSONListResponse

func JSONListResponse(fn func() (interface{}, error), w http.ResponseWriter, r *http.Request)

func JSONResponse

func JSONResponse(payload interface{}, w http.ResponseWriter, r *http.Request)

func JSONResponseWithStatus

func JSONResponseWithStatus(httpStatus int, payload interface{}, w http.ResponseWriter, r *http.Request)

func JSONUpdateResponse

func JSONUpdateResponse(i interface{}, fn func(string) error, w http.ResponseWriter, r *http.Request)

func RoundToTwoDecimal

func RoundToTwoDecimal(f float64) float64

RoundToTwoDecimal Round float64 to 2 decimals

func SummarizeAPI

func SummarizeAPI()

func SystemdExecute

func SystemdExecute(name, command string, w bool) error

Types

type Auth

type Auth interface {
	SignIn(http.ResponseWriter, *http.Request)
	SignOut(http.ResponseWriter, *http.Request)
	GetCredentials() (Credentials, error)
	UpdateCredentials(http.ResponseWriter, *http.Request)
	Me(http.ResponseWriter, *http.Request)
	Authenticate(http.HandlerFunc) http.HandlerFunc
}

func NewAuth

func NewAuth(b string, store storage.Store) Auth

type CalibrationConfiguration

type CalibrationConfiguration struct {
	Type         CalibrationType `json:"Points"`
	Measurements []Measurement   `json:"measurements"`
}

type CalibrationType

type CalibrationType int
const (
	OnePointCalibration CalibrationType = iota + 1
	TwoPointCalibration
)

type Calibrator

type Calibrator interface {
	Calibrate(float64) float64
}

func CalibratorFactory

func CalibratorFactory(config CalibrationConfiguration) (Calibrator, error)

type Credentials

type Credentials struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

type Doer

type Doer interface {
	Do(func(interface{}))
}

type ExecCommand

type ExecCommand struct {
	DevMode bool
	// contains filtered or unexported fields
}

func Command

func Command(bin string, args ...string) *ExecCommand

func (*ExecCommand) CombinedOutput

func (e *ExecCommand) CombinedOutput() ([]byte, error)

func (*ExecCommand) Run

func (e *ExecCommand) Run() error

func (*ExecCommand) RunDetached

func (e *ExecCommand) RunDetached() error

func (*ExecCommand) WithDevMode

func (e *ExecCommand) WithDevMode(b bool) *ExecCommand

type Measurement

type Measurement struct {
	Actual   float64 `json:"actual"`
	Expected float64 `json:"expected"`
}

type TestRouter

type TestRouter struct {
	Router *mux.Router
}

func NewTestRouter

func NewTestRouter() *TestRouter

func (*TestRouter) Do

func (t *TestRouter) Do(method, path string, body io.Reader, container interface{}) error

Jump to

Keyboard shortcuts

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