server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Copyright © 2022 Sloan Childers

Index

Constants

This section is empty.

Variables

View Source
var ErrCameraNotFound = errors.New("camera not found")

Functions

func GetDSN

func GetDSN(cfg *Config) string

func InitLogger

func InitLogger(level string)

TODO: all this boilerplate stuff needs it's own repo

func ListenAndServe

func ListenAndServe(cfg *Config, router *chi.Mux)

func LoadEnv

func LoadEnv(output interface{})

func LoadJson

func LoadJson(fileName string, cfg interface{}) error

func OpenDB

func OpenDB(cfg *Config) *gorm.DB

func Param

func Param(r *http.Request, key string) string

func PrintEnvironment

func PrintEnvironment()

func SendError

func SendError(w http.ResponseWriter, err error, status int)

func SendPrettyJSON

func SendPrettyJSON(ctx context.Context, w http.ResponseWriter, data interface{})

func Start

func Start()

Types

type Config

type Config struct {
	FilesystemPath string `env:"LOCAL_DB_PATH" envDefault:"./external/"`
	PathPrefix     string `env:"PATH_PREFIX" envDefault:"/"`
	ListenAddr     string `env:"LISTEN_ADDR,required" envDefault:"127.0.0.1:8080"`
	LogLevel       string `env:"LOG_LEVEL" envDefault:"TRACE"`
	PgDB           string `env:"POSTGRES_DB" envDefault:"postgres"`
	PgHost         string `env:"POSTGRES_HOST" envDefault:"127.0.0.1"`
	PgHostAuth     string `env:"POSTGRES_HOST_AUTH_METHOD" envDefault:"trust"`
	PgPassword     string `env:"POSTGRES_PASSWORD" envDefault:"postgres"`
	PgPort         string `env:"POSTGRES_PORT" envDefault:"5432"`
	PgUser         string `env:"POSTGRES_USER" envDefault:"postgres"`
	SSLCertFile    string `env:"CERT_FILE"`
	SSLKeyFile     string `env:"KEY_FILE"`
}

type ShutdownHandler

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

func NewShutdownHandler

func NewShutdownHandler() *ShutdownHandler

func (*ShutdownHandler) AddListener

func (x *ShutdownHandler) AddListener(f func())

func (*ShutdownHandler) Listen

func (x *ShutdownHandler) Listen()

type VideoRecorder

type VideoRecorder struct {
}

func NewVideoServer

func NewVideoServer() *VideoRecorder

func (*VideoRecorder) CameraStartHandler

func (x *VideoRecorder) CameraStartHandler(w http.ResponseWriter, r *http.Request)

func (*VideoRecorder) CameraStopHandler

func (x *VideoRecorder) CameraStopHandler(w http.ResponseWriter, r *http.Request)

func (*VideoRecorder) CameraStreamHandler

func (x *VideoRecorder) CameraStreamHandler(w http.ResponseWriter, r *http.Request)

func (*VideoRecorder) ShutdownHandler

func (x *VideoRecorder) ShutdownHandler(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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