Documentation ¶
Overview ¶
Package ls-fibre includes generic handlers, net/http and mux code for instances of servers with API endpoints further defined within their respective packages.
Index ¶
- type ProxyConfig
- type ProxyOverride
- type WebService
- func (ws *WebService) APIKeyMiddleware(next http.Handler) http.Handler
- func (ws *WebService) FavicoHandler(w http.ResponseWriter, r *http.Request)
- func (ws *WebService) HealthCheckHandler(w http.ResponseWriter, r *http.Request)
- func (ws *WebService) HomeHandler(w http.ResponseWriter, r *http.Request)
- func (ws *WebService) JsonStatusResponse(w http.ResponseWriter, response string, status int)
- func (ws *WebService) LogMiddleware(next http.Handler) http.Handler
- func (ws *WebService) NotFoundHandler(w http.ResponseWriter, r *http.Request)
- func (ws *WebService) PageHandler(w http.ResponseWriter, r *http.Request)
- func (ws *WebService) Proxy(config []ProxyConfig)
- func (ws *WebService) RunWebServer()
- func (ws *WebService) SetupProxy(config ProxyConfig) http.Handler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProxyConfig ¶
type ProxyConfig struct { Path string Host string Override ProxyOverride }
type ProxyOverride ¶
type WebService ¶
struct WebService holds a Router (*mux.Router), Instance name (string), Address (string), and optional Apikey (string).
func NewWebService ¶
func NewWebService(instance string, address string) *WebService
Create a web service with appropriate handlers. instance is a key that will be used in loading templates, static files, etc. address is the host and port to listen on
func (*WebService) APIKeyMiddleware ¶
func (ws *WebService) APIKeyMiddleware(next http.Handler) http.Handler
APIKeyMiddleware provides a built in check for api key, for json api services
func (*WebService) FavicoHandler ¶
func (ws *WebService) FavicoHandler(w http.ResponseWriter, r *http.Request)
func (*WebService) HealthCheckHandler ¶
func (ws *WebService) HealthCheckHandler(w http.ResponseWriter, r *http.Request)
HealthCheckHandler provides a default health check response (in JSON) for the instance.
func (*WebService) HomeHandler ¶
func (ws *WebService) HomeHandler(w http.ResponseWriter, r *http.Request)
Home handler provides a default index handler for the instance.
func (*WebService) JsonStatusResponse ¶
func (ws *WebService) JsonStatusResponse(w http.ResponseWriter, response string, status int)
JsonStatusResponse takees a response writer, response string and status, and writes the status and encodes the response string.
func (*WebService) LogMiddleware ¶
func (ws *WebService) LogMiddleware(next http.Handler) http.Handler
LogMiddleware simply prints request URIs.
func (*WebService) NotFoundHandler ¶
func (ws *WebService) NotFoundHandler(w http.ResponseWriter, r *http.Request)
NotFoundHandler provides a default not found handler for the instance.
func (*WebService) PageHandler ¶
func (ws *WebService) PageHandler(w http.ResponseWriter, r *http.Request)
Generic handler for /page/<page>.html requests, which reads from the root/web/<instance>/templates/<page>.html template.
func (*WebService) Proxy ¶
func (ws *WebService) Proxy(config []ProxyConfig)
func (*WebService) RunWebServer ¶
func (ws *WebService) RunWebServer()
Creates a new net/http service with a WebService configuration, then run the http.Server
func (*WebService) SetupProxy ¶
func (ws *WebService) SetupProxy(config ProxyConfig) http.Handler