Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddHandlerFunc ¶
func AddHandlerFunc(api string, h HandlerFunc) error
AddHandlerFunc adds a handler to the global handler map. Callbacks should be added before calling NewWithDefaultRoutes() This is NOT threadsafe
Types ¶
type Config ¶
type Config struct { Enabled bool `config:"enabled"` Host string `config:"host"` Port int `config:"port"` User string `config:"named_pipe.user"` SecurityDescriptor string `config:"named_pipe.security_descriptor"` Timeout time.Duration `config:"timeout"` }
Config is the configuration for the API endpoint.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig is the default configuration used by the API endpoint.
type HandlerFunc ¶ added in v0.3.5
type HandlerFunc func(http.ResponseWriter, *http.Request)
HandlerFunc is an http callback
func MakeAPIHandler ¶ added in v0.3.5
func MakeAPIHandler(ns *monitoring.Namespace) HandlerFunc
MakeAPIHandler creates an API handler for the given namespace
func MakeRootAPIHandler ¶ added in v0.3.5
func MakeRootAPIHandler(handler HandlerFunc) HandlerFunc
MakeRootAPIHandler creates a HandlerFunc for the root / path
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server takes cares of correctly starting the HTTP component of the API and will answers all the routes defined in the received ServeMux.
func NewWithDefaultRoutes ¶
NewWithDefaultRoutes creates a new server with default API routes.
func (*Server) AddRoute ¶ added in v0.3.5
func (s *Server) AddRoute(path string, handler HandlerFunc)
AddRoute adds a route to the server mux
func (*Server) AttachHandler ¶
AttachHandler will attach a handler at the specified route and return an error instead of panicing.
func (*Server) AttachPprof ¶
func (s *Server) AttachPprof()
AttachPprof adds /debug/pprof endpoints to the server