server

package
v0.0.0-...-717731b Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package server provides a RESTful HTTP interface for the cold brew coffee dripper.

Index

Constants

View Source
const (
	// EnvDevelopment is a constant used to determine if the application is in a
	// development environment.
	EnvDevelopment = "development"

	// EnvProduction is a constant used to determine if the application is in a
	// production environment.
	EnvProduction = "production"

	// EnvTesting is a constant used to determine if the application is in a
	// testing environment.
	EnvTesting = "testing"
)

Variables

This section is empty.

Functions

func NewDatabase

func NewDatabase(dir string) (*scribble.Driver, error)

NewDatabase creates a new filesystem based database given the base directory.

Types

type Config

type Config struct {
	// Environment is used to determine which environment the cold brew dirpper
	// application is being run in.
	Environment string

	// DatabaseDir is the absolute path of the SQLite database.
	DatabaseDir string
}

Config is a configuration struct used by the server package to configure downstream dependencies.

func NewConfig

func NewConfig() (*Config, error)

NewConfig returns a new configuration struct populated from a config file.

type Server

type Server struct {
	Dripper *dripper.Dripper
	Config  *Config
	DB      *scribble.Driver
}

Server is a base object which provide HTTP requests access to the dripper.

func New

func New() *Server

New creates a new server instance.

func (*Server) GetDripper

func (s *Server) GetDripper(c *gin.Context)

GetDripper returns the current state of the cold brew dripper.

func (*Server) GetDripperSettings

func (s *Server) GetDripperSettings(c *gin.Context)

GetDripperSettings returns the current configuration of the dripper.

func (*Server) SetDripperDrip

func (s *Server) SetDripperDrip(c *gin.Context)

SetDripperDrip sets the dripper to the drip state.

func (*Server) SetDripperOff

func (s *Server) SetDripperOff(c *gin.Context)

SetDripperOff sets the dripper to the off state.

func (*Server) SetDripperRun

func (s *Server) SetDripperRun(c *gin.Context)

SetDripperRun sets the dripper to the run state.

func (*Server) SetDripperSettings

func (s *Server) SetDripperSettings(c *gin.Context)

SetDripperSettings reinitializes the dripper with the supplied config.

Jump to

Keyboard shortcuts

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