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

Function parseRequest

pkg/ruler/api.go:475–498  ·  view source on GitHub ↗

parseRequest parses the incoming request to parse out the userID, rules namespace, and rule group name and returns them in that order. It also allows users to require a namespace or group name and return an error if it they can not be parsed.

(req *http.Request, requireNamespace, requireGroup bool)

Source from the content-addressed store, hash-verified

473// and returns them in that order. It also allows users to require a namespace or group name and return
474// an error if it they can not be parsed.
475func parseRequest(req *http.Request, requireNamespace, requireGroup bool) (string, string, string, error) {
476 userID, err := users.TenantID(req.Context())
477 if err != nil {
478 return "", "", "", user.ErrNoOrgID
479 }
480
481 vars := mux.Vars(req)
482
483 namespace, err := parseNamespace(vars)
484 if err != nil {
485 if err != ErrNoNamespace || requireNamespace {
486 return "", "", "", err
487 }
488 }
489
490 group, err := parseGroupName(vars)
491 if err != nil {
492 if err != ErrNoGroupName || requireGroup {
493 return "", "", "", err
494 }
495 }
496
497 return userID, namespace, group, nil
498}
499
500func (a *API) ListRules(w http.ResponseWriter, req *http.Request) {
501 logger := util_log.WithContext(req.Context(), a.logger)

Callers 5

ListRulesMethod · 0.85
GetRuleGroupMethod · 0.85
CreateRuleGroupMethod · 0.85
DeleteNamespaceMethod · 0.85
DeleteRuleGroupMethod · 0.85

Calls 4

TenantIDFunction · 0.92
parseNamespaceFunction · 0.85
parseGroupNameFunction · 0.85
ContextMethod · 0.45

Tested by

no test coverage detected