MCPcopy
hub / github.com/grafana/dskit / formatValue

Function formatValue

kv/memberlist/http_status_handler.go:194–213  ·  view source on GitHub ↗
(w http.ResponseWriter, val interface{}, format string)

Source from the content-addressed store, hash-verified

192}
193
194func formatValue(w http.ResponseWriter, val interface{}, format string) {
195 w.WriteHeader(200)
196 w.Header().Add("content-type", "text/plain")
197
198 switch format {
199 case "json", "json-pretty":
200 enc := json.NewEncoder(w)
201 if format == "json-pretty" {
202 enc.SetIndent("", " ")
203 }
204
205 err := enc.Encode(val)
206 if err != nil {
207 http.Error(w, err.Error(), http.StatusInternalServerError)
208 }
209
210 default:
211 _, _ = fmt.Fprintf(w, "%#v", val)
212 }
213}
214
215func downloadKey(w http.ResponseWriter, kv *KV, store map[string]ValueDesc, key string) {
216 if store[key].value == nil {

Callers 2

viewMessageFunction · 0.85
viewKeyFunction · 0.85

Calls 5

AddMethod · 0.65
EncodeMethod · 0.65
WriteHeaderMethod · 0.45
HeaderMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected