ostent

package
Version: v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2016 License: MIT Imports: 20 Imported by: 6

Documentation

Overview

Package ostent is the library part of ostent cmd.

Index

Constants

View Source
const (
	CAssetPath contextID = iota
	CRouterParams
)

Variables

View Source
var OstentUpgrade = new(UpgradeInfo)

Functions

func AddAssetPathContextFunc

func AddAssetPathContextFunc(path string) func(http.Handler) http.Handler

func AddExporter added in v0.7.0

func AddExporter(header, text string)

func ContextParam added in v0.7.0

func ContextParam(r *http.Request, pname string) (string, error)

ContextParam is to retrieve pname param from context params.

func Distrib added in v0.6.1

func Distrib() (string, error)

Distrib is to return distribution identifier string with version.

func Fetch added in v0.6.1

func Fetch(keys *params.FetchKeys) error

func FetchExtract added in v0.6.1

func FetchExtract(jdata *gabs.Container, keys []string) (*gabs.Container, interface{})

func HandleFunc added in v0.6.2

func HandleFunc(hf http.HandlerFunc) httprouter.Handle

HandleFunc wraps hf into handle.

func HandleThen added in v0.6.2

func HandleThen(then func(http.Handler) http.Handler) func(http.HandlerFunc) httprouter.Handle

HandleThen wraps then(hf) into handle.

func LogHandler added in v0.6.2

func LogHandler(logRequests bool, h http.Handler) http.Handler

func ParamsFunc added in v0.6.2

func ParamsFunc(then func(http.Handler) http.Handler) func(http.HandlerFunc) httprouter.Handle

ParamsFunc wraps then(hf) into handle with context setting by handleParamSetContext.

func ServerHandler added in v0.6.2

func ServerHandler(logRequests bool, h http.Handler) http.Handler

func UpdateLoop added in v0.7.0

func UpdateLoop()

UpdateLoop pushes updates to connections.

Types

type IndexData

type IndexData map[string]interface{}

IndexData is a data map for templates and marshalling. Keys (even abbrevs eg CPU) intentionally start with lowercase.

func Updates

func Updates(req *http.Request, para *params.Params) (IndexData, bool, error)

type SSE

type SSE struct {
	Writer      http.ResponseWriter // points to the writer
	Params      *params.Params
	SentHeaders bool
	Errord      bool
}

func (*SSE) ServeHTTP

func (sse *SSE) ServeHTTP(_ http.ResponseWriter, r *http.Request)

ServeHTTP is a regular serve func except the first argument, passed as a copy, is unused. sse.Writer is there for writes.

func (*SSE) SetHeader

func (sse *SSE) SetHeader(name, value string) bool

type ServeAssets

type ServeAssets struct {
	Logger         logger
	ReadFunc       func(string) ([]byte, error)
	InfoFunc       func(string) (os.FileInfo, error)
	AltModTimeFunc func() time.Time // may be nil
}

func (ServeAssets) Serve

func (sa ServeAssets) Serve(w http.ResponseWriter, r *http.Request)

Serve does http.ServeContent with asset content and info.

type ServeIndex

type ServeIndex struct {
	ServeWS
	StaticData
	IndexTemplate *templateutil.LazyTemplate
}

func NewServeIndex

func NewServeIndex(sw ServeWS, template *templateutil.LazyTemplate, sd StaticData) ServeIndex

func (ServeIndex) Index

func (si ServeIndex) Index(w http.ResponseWriter, r *http.Request)

Index renders index page.

type ServeSSE

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

func NewServeSSE

func NewServeSSE(logRequests bool) ServeSSE

func (ServeSSE) IndexSSE

func (ss ServeSSE) IndexSSE(w http.ResponseWriter, r *http.Request)

IndexSSE serves SSE updates.

type ServeWS

type ServeWS struct {
	ServeSSE
	// contains filtered or unexported fields
}

func NewServeWS

func NewServeWS(se ServeSSE, lg logger) ServeWS

func (ServeWS) IndexWS

func (sw ServeWS) IndexWS(w http.ResponseWriter, req *http.Request)

IndexWS serves ws updates.

type StaticData added in v0.7.0

type StaticData struct {
	TAGGEDbin     bool
	Distrib       string
	OstentVersion string
}

type UpgradeInfo added in v0.6.1

type UpgradeInfo struct {
	RWMutex       sync.RWMutex
	LatestVersion string
}

func (*UpgradeInfo) Get added in v0.6.1

func (ui *UpgradeInfo) Get() string

func (*UpgradeInfo) Set added in v0.6.1

func (ui *UpgradeInfo) Set(lv string)

Jump to

Keyboard shortcuts

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