MCPcopy Index your code
hub / github.com/cortexproject/cortex / RegisterRoutes

Method RegisterRoutes

pkg/configs/api/api.go:87–110  ·  view source on GitHub ↗

RegisterRoutes registers the configs API HTTP routes with the provided Router.

(r *mux.Router)

Source from the content-addressed store, hash-verified

85
86// RegisterRoutes registers the configs API HTTP routes with the provided Router.
87func (a *API) RegisterRoutes(r *mux.Router) {
88 for _, route := range []struct {
89 name, method, path string
90 handler http.HandlerFunc
91 }{
92 {"root", "GET", "/", a.admin},
93 // Dedicated APIs for updating rules config. In the future, these *must*
94 // be used.
95 {"get_rules", "GET", "/api/prom/configs/rules", a.getConfig},
96 {"set_rules", "POST", "/api/prom/configs/rules", a.setConfig},
97 {"get_templates", "GET", "/api/prom/configs/templates", a.getConfig},
98 {"set_templates", "POST", "/api/prom/configs/templates", a.setConfig},
99 {"get_alertmanager_config", "GET", "/api/prom/configs/alertmanager", a.getConfig},
100 {"set_alertmanager_config", "POST", "/api/prom/configs/alertmanager", a.setConfig},
101 {"validate_alertmanager_config", "POST", "/api/prom/configs/alertmanager/validate", a.validateAlertmanagerConfig},
102 {"deactivate_config", "DELETE", "/api/prom/configs/deactivate", a.deactivateConfig},
103 {"restore_config", "POST", "/api/prom/configs/restore", a.restoreConfig},
104 // Internal APIs.
105 {"private_get_rules", "GET", "/private/api/prom/configs/rules", a.getConfigs},
106 {"private_get_alertmanager_config", "GET", "/private/api/prom/configs/alertmanager", a.getConfigs},
107 } {
108 r.Handle(route.path, route.handler).Methods(route.method).Name(route.name)
109 }
110}
111
112// getConfig returns the request configuration.
113func (a *API) getConfig(w http.ResponseWriter, r *http.Request) {

Callers 2

NewFunction · 0.95
initConfigMethod · 0.80

Calls 2

NameMethod · 0.65
HandleMethod · 0.65

Tested by

no test coverage detected