Documentation
¶
Index ¶
- Variables
- func Asset(name string) ([]byte, error)
- func AssetDir(name string) ([]string, error)
- func AssetInfo(name string) (os.FileInfo, error)
- func AssetNames() []string
- func Logger(handler http.Handler, name string, verbose bool) http.Handler
- func MustAsset(name string) []byte
- func NilHandler(w http.ResponseWriter, _ *http.Request)
- func RestoreAsset(dir, name string) error
- func RestoreAssets(dir, name string) error
- func StartServer(version string, rbox *regenbox.RegenBox, cfg *Config, cfgPath string, ...)
- func WrapCustomRW(wr http.ResponseWriter) http.ResponseWriter
- type Battery
- type ChartLog
- type ChartLogInfo
- type Config
- type CustomResponseWriter
- type Link
- type Server
- func (s *Server) Chart(w http.ResponseWriter, r *http.Request)
- func (s *Server) Charts(w http.ResponseWriter, r *http.Request)
- func (s *Server) Home(w http.ResponseWriter, r *http.Request)
- func (s *Server) LiveData(w http.ResponseWriter, r *http.Request)
- func (s *Server) RegenboxConfigHandler(w http.ResponseWriter, r *http.Request)
- func (s *Server) RenderCss(name string, data interface{}) template.CSS
- func (s *Server) RenderHtml(name string, data interface{}) template.HTML
- func (s *Server) RenderJs(name string, data interface{}) template.JS
- func (s *Server) Snapshot(w http.ResponseWriter, r *http.Request)
- func (s *Server) StartRegenbox(w http.ResponseWriter, r *http.Request)
- func (s *Server) Static(w http.ResponseWriter, r *http.Request)
- func (s *Server) StopRegenbox(w http.ResponseWriter, r *http.Request)
- func (s *Server) Websocket(w http.ResponseWriter, r *http.Request)
- type ServerConfig
- type TemplateData
- type User
Constants ¶
This section is empty.
Variables ¶
var ChartsLink = Link{
Href: "/charts",
Name: "Charts",
}
var DefaultConfig = Config{ User: NoName, Battery: NoBattery, Resistor: 10, Web: DefaultServerConfig, Regenbox: regenbox.DefaultConfig, Watcher: regenbox.DefaultWatcherConfig, Serial: regenbox.DefaultSerialConfig, }
var DefaultServerConfig = ServerConfig{ ListenAddr: "localhost:3636", StaticDir: "static", DataDir: "data", WebsocketInterval: util.Duration(time.Second), }
var HomeLink = Link{
Href: "/",
Name: "Live",
}
var NoBattery = Battery{}
var NoName = User{}
Functions ¶
func Asset ¶
Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.
func AssetDir ¶
AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:
data/ foo.txt img/ a.png b.png
then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.
func AssetInfo ¶
AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.
func MustAsset ¶
MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.
func NilHandler ¶
func NilHandler(w http.ResponseWriter, _ *http.Request)
func RestoreAsset ¶
RestoreAsset restores an asset under the given directory
func RestoreAssets ¶
RestoreAssets restores an asset under the given directory recursively
func StartServer ¶
func StartServer(version string, rbox *regenbox.RegenBox, cfg *Config, cfgPath string, verbose bool)
StartServer starts a new http.Server using provided version, RegenBox & Config. It either doesn't return or panics (http.Listen)
func WrapCustomRW ¶
func WrapCustomRW(wr http.ResponseWriter) http.ResponseWriter
Types ¶
type ChartLog ¶
type ChartLog struct { User User Battery Battery Resistor int CycleType string TargetReached bool Reason string TotalDuration util.Duration Config regenbox.Config Measures util.TimeSeries }
func (ChartLog) Info ¶
func (cl ChartLog) Info() ChartLogInfo
type ChartLogInfo ¶
type ChartLogInfo struct { User User Battery Battery CycleType string StartTime time.Time EndTime time.Time Interval util.Duration // contains filtered or unexported fields }
func ListChartLogs ¶
func ListChartLogs(dir string) (err error, infos []ChartLogInfo)
func (ChartLogInfo) FileName ¶
func (cli ChartLogInfo) FileName() string
func (ChartLogInfo) Path ¶
func (cli ChartLogInfo) Path() string
func (ChartLogInfo) String ¶
func (cli ChartLogInfo) String() string
type Config ¶
type Config struct { User User Battery Battery Resistor int Regenbox regenbox.Config Web ServerConfig Watcher regenbox.WatcherConfig Serial serial.Mode }
type CustomResponseWriter ¶
type CustomResponseWriter struct { http.ResponseWriter Status int }
CustomResponseWriter allows to store current status code of ResponseWriter.
func (*CustomResponseWriter) Header ¶
func (w *CustomResponseWriter) Header() http.Header
func (*CustomResponseWriter) Hijack ¶
func (w *CustomResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*CustomResponseWriter) WriteHeader ¶
func (w *CustomResponseWriter) WriteHeader(statusCode int)
type Server ¶
type Server struct { Config *Config Regenbox *regenbox.RegenBox sync.Mutex // contains filtered or unexported fields }
func (*Server) Chart ¶
func (s *Server) Chart(w http.ResponseWriter, r *http.Request)
Chart encodes ChartLog from path as json to w.
func (*Server) Charts ¶
func (s *Server) Charts(w http.ResponseWriter, r *http.Request)
Explorer page
func (*Server) Home ¶
func (s *Server) Home(w http.ResponseWriter, r *http.Request)
Home serves homepage
func (*Server) LiveData ¶
func (s *Server) LiveData(w http.ResponseWriter, r *http.Request)
LiveData encodes live measurement log as json to w.
func (*Server) RegenboxConfigHandler ¶
func (s *Server) RegenboxConfigHandler(w http.ResponseWriter, r *http.Request)
RegenboxConfigHandler POST: s.Regenbox.SetConfig() (json encoded),
Regenbox's must be stopped first GET: gets current s.Regenbox.Config()
func (*Server) RenderHtml ¶
RenderHtml renders un-espaced html asset
func (*Server) Snapshot ¶
func (s *Server) Snapshot(w http.ResponseWriter, r *http.Request)
Snapshot encodes snapshot as json to w.
func (*Server) StartRegenbox ¶
func (s *Server) StartRegenbox(w http.ResponseWriter, r *http.Request)
func (*Server) Static ¶
func (s *Server) Static(w http.ResponseWriter, r *http.Request)
Static server
func (*Server) StopRegenbox ¶
func (s *Server) StopRegenbox(w http.ResponseWriter, r *http.Request)
type ServerConfig ¶
type TemplateData ¶
type TemplateData struct { *Config Link Link DataDir string CycleMsg *regenbox.CycleMessage ChartLogs []ChartLogInfo Error error Version string }