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

Function DefaultConfigHandler

pkg/api/handlers.go:125–157  ·  view source on GitHub ↗
(actualCfg any, defaultCfg any)

Source from the content-addressed store, hash-verified

123}
124
125func DefaultConfigHandler(actualCfg any, defaultCfg any) http.HandlerFunc {
126 return func(w http.ResponseWriter, r *http.Request) {
127 var output any
128 switch r.URL.Query().Get("mode") {
129 case "diff":
130 defaultCfgObj, err := util.YAMLMarshalUnmarshal(defaultCfg)
131 if err != nil {
132 http.Error(w, err.Error(), http.StatusInternalServerError)
133 return
134 }
135
136 actualCfgObj, err := util.YAMLMarshalUnmarshal(actualCfg)
137 if err != nil {
138 http.Error(w, err.Error(), http.StatusInternalServerError)
139 return
140 }
141
142 diff, err := util.DiffConfig(defaultCfgObj, actualCfgObj)
143 if err != nil {
144 http.Error(w, err.Error(), http.StatusInternalServerError)
145 return
146 }
147 output = diff
148
149 case "defaults":
150 output = defaultCfg
151 default:
152 output = actualCfg
153 }
154
155 util.WriteYAMLResponse(w, output)
156 }
157}
158
159// NewQuerierHandler returns a HTTP handler that can be used by the querier service to
160// either register with the frontend worker query processor or with the external HTTP

Callers 2

TestConfigDiffHandlerFunction · 0.85
configHandlerMethod · 0.85

Calls 6

YAMLMarshalUnmarshalFunction · 0.92
DiffConfigFunction · 0.92
WriteYAMLResponseFunction · 0.92
GetMethod · 0.65
QueryMethod · 0.65
ErrorMethod · 0.45

Tested by 1

TestConfigDiffHandlerFunction · 0.68