(prefix string, handler http.Handler, auth bool, methods ...string)
| 211 | } |
| 212 | |
| 213 | func (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) |
| 215 | if auth { |
| 216 | handler = a.AuthMiddleware.Wrap(handler) |
| 217 | } |
| 218 | |
| 219 | if a.cfg.ResponseCompression { |
| 220 | handler = gzhttp.GzipHandler(handler) |
| 221 | } |
| 222 | if a.HTTPHeaderMiddleware != nil { |
| 223 | handler = a.HTTPHeaderMiddleware.Wrap(handler) |
| 224 | } |
| 225 | |
| 226 | if len(methods) == 0 { |
| 227 | a.server.HTTP.PathPrefix(prefix).Handler(handler) |
| 228 | return |
| 229 | } |
| 230 | a.server.HTTP.PathPrefix(prefix).Methods(methods...).Handler(handler) |
| 231 | } |
| 232 | |
| 233 | // RegisterAlertmanager registers endpoints associated with the alertmanager. It will only |
| 234 | // serve endpoints using the legacy http-prefix if it is not run as a single binary. |
no test coverage detected