Documentation
¶
Index ¶
- Variables
- func ExpandPath(c *gabs.Container, token *list.Element, res *bytes.Buffer)
- func HealthHandler(w http.ResponseWriter, r *http.Request)
- func IndexHandler(ctx *Context, w http.ResponseWriter, r *http.Request) (int, error)
- func MakeReloadCallback(c *Context, configName string) func()
- func ParseYaml(fname string) (*gabs.Container, error)
- func UpdateHosts(c *Context)
- func ValidateConfig(c *gabs.Container) error
- func VarsHandler(c *Context, w http.ResponseWriter, r *http.Request) (int, error)
- func WatchConfigFileChanges(watcher *fsnotify.Watcher, fname string, cb func())
- type Context
- type CtxWrapper
Constants ¶
This section is empty.
Variables ¶
var Afero = &afero.Afero{Fs: afero.NewOsFs()}
Afero is a filesystem wrapper providing util methods and easy test mocks.
Functions ¶
func ExpandPath ¶ added in v1.4.0
ExpandPath takes a Config, list of tokens (parsed from request) and the results buffer At each level of recursion, it matches the token to the action described in the Config, and writes it to the result buffer. There is special care needed to handle slashes correctly, which makes this function quite nontrivial. Tests are crucial to ensure correctness.
func HealthHandler ¶
func HealthHandler(w http.ResponseWriter, r *http.Request)
HealthHandler responds to /healthz request.
func IndexHandler ¶
IndexHandler handles all the non status expansions.
func MakeReloadCallback ¶
MakeReloadCallback returns a func that that reads the config file and updates global state.
func UpdateHosts ¶
func UpdateHosts(c *Context)
TODO: add tests. simulate touching a file. UpdateHosts will attempt to write the zap list of shortcuts to /etc/hosts. It will gracefully fail if there are not enough permissions to do so.
func ValidateConfig ¶
func ValidateConfig(c *gabs.Container) error
ValidateConfig verifies that there are no unexpected values in the Config file. at each level of the Config, we should either have a KV for expansions, or a leaf node with the values oneof "expand", "query", "ssl_off" that map to a string.
func VarsHandler ¶
VarsHandler responds to /varz request and prints Config.
func WatchConfigFileChanges ¶
WatchConfigFileChanges will attach an fsnotify watcher to the config file, and trigger the cb function when the file is updated.
Types ¶
type CtxWrapper ¶
type CtxWrapper struct { *Context H func(*Context, http.ResponseWriter, *http.Request) (int, error) }
func (CtxWrapper) ServeHTTP ¶
func (cw CtxWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request)