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

Method RegisterRoute

pkg/api/api.go:190–211  ·  view source on GitHub ↗

RegisterRoute registers a single route enforcing HTTP methods. A single route is expected to be specific about which HTTP methods are supported.

(path string, handler http.Handler, auth bool, method string, methods ...string)

Source from the content-addressed store, hash-verified

188// RegisterRoute registers a single route enforcing HTTP methods. A single
189// route is expected to be specific about which HTTP methods are supported.
190func (a *API) RegisterRoute(path string, handler http.Handler, auth bool, method string, methods ...string) {
191 methods = append([]string{method}, methods...)
192
193 level.Debug(a.logger).Log("msg", "api: registering route", "methods", strings.Join(methods, ","), "path", path, "auth", auth)
194
195 if auth {
196 handler = a.AuthMiddleware.Wrap(handler)
197 }
198
199 if a.cfg.ResponseCompression {
200 handler = gzhttp.GzipHandler(handler)
201 }
202 if a.HTTPHeaderMiddleware != nil {
203 handler = a.HTTPHeaderMiddleware.Wrap(handler)
204 }
205
206 if len(methods) == 0 {
207 a.server.HTTP.Path(path).Handler(handler)
208 return
209 }
210 a.server.HTTP.Path(path).Methods(methods...).Handler(handler)
211}
212
213func (a *API) RegisterRoutesWithPrefix(prefix string, handler http.Handler, auth bool, methods ...string) {
214 level.Debug(a.logger).Log("msg", "api: registering route", "methods", strings.Join(methods, ","), "prefix", prefix, "auth", auth)

Callers 15

RegisterAlertmanagerMethod · 0.95
RegisterAPIMethod · 0.95
RegisterRuntimeConfigMethod · 0.95
RegisterDistributorMethod · 0.95
RegisterIngesterMethod · 0.95
RegisterRulerMethod · 0.95
RegisterRulerAPIMethod · 0.95
RegisterOverridesMethod · 0.95
RegisterRingMethod · 0.95
RegisterStoreGatewayMethod · 0.95
RegisterCompactorMethod · 0.95

Calls 3

JoinMethod · 0.80
WrapMethod · 0.65
LogMethod · 0.45

Tested by 1

Benchmark_CompressionFunction · 0.64