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

Function parseConfigFormat

pkg/configs/api/api.go:354–372  ·  view source on GitHub ↗
(v string, defaultFormat string)

Source from the content-addressed store, hash-verified

352)
353
354func parseConfigFormat(v string, defaultFormat string) string {
355 if v == "" {
356 return defaultFormat
357 }
358 parts := strings.SplitSeq(v, ",")
359 for part := range parts {
360 mimeType, _, err := mime.ParseMediaType(part)
361 if err != nil {
362 continue
363 }
364 switch mimeType {
365 case "application/json":
366 return FormatJSON
367 case "text/yaml", "text/x-yaml", "application/yaml", "application/x-yaml":
368 return FormatYAML
369 }
370 }
371 return defaultFormat
372}

Callers 3

getConfigMethod · 0.85
setConfigMethod · 0.85
TestParseConfigFormatFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestParseConfigFormatFunction · 0.68