Documentation
¶
Overview ¶
Package api hosts the HTTP control-plane for watchtower (token auth, /v1/update, /v1/metrics).
Index ¶
- Constants
- type API
- func (api *API) RegisterFunc(path string, fn http.HandlerFunc)
- func (api *API) RegisterHandler(path string, handler http.Handler)
- func (api *API) RegisterPublicHandler(path string, handler http.Handler)
- func (api *API) RequireToken(fn http.HandlerFunc) http.HandlerFunc
- func (api *API) Start(block bool) error
Constants ¶
const ( // DefaultListenAddr is used when --http-api-host isn't set. Binds to // every interface on port 8080, matching the pre-v1.12 behavior. DefaultListenAddr = ":8080" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
API is the http server responsible for serving the HTTP API endpoints
func (*API) RegisterFunc ¶
func (api *API) RegisterFunc(path string, fn http.HandlerFunc)
RegisterFunc is a wrapper around http.HandleFunc that also sets the flag used to determine whether to launch the API
func (*API) RegisterHandler ¶
RegisterHandler is a wrapper around http.Handler that also sets the flag used to determine whether to launch the API
func (*API) RegisterPublicHandler ¶ added in v1.11.0
RegisterPublicHandler registers a handler without token auth. Used for the Prometheus /v1/metrics endpoint when --http-api-metrics-no-auth is set — Prometheus scraping is conventionally unauthenticated on trusted networks and bearer-token plumbing for every scraper is friction-for-no-gain in that setup. Network-level controls (localhost bind, reverse proxy, firewall) are expected to provide the real access boundary.
func (*API) RequireToken ¶
func (api *API) RequireToken(fn http.HandlerFunc) http.HandlerFunc
RequireToken is wrapper around http.HandleFunc that checks token validity using a constant-time comparison so watchtower isn't a timing oracle for operators who expose :8080 to an untrusted network.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package audit exposes the HTTP handler for the /v1/audit endpoint.
|
Package audit exposes the HTTP handler for the /v1/audit endpoint. |
|
Package metrics exposes the Prometheus /v1/metrics HTTP handler.
|
Package metrics exposes the Prometheus /v1/metrics HTTP handler. |
|
Package update exposes the HTTP handler for the /v1/update API endpoint.
|
Package update exposes the HTTP handler for the /v1/update API endpoint. |