MCPcopy Index your code
hub / github.com/coder/coder / parseQueryParamSet

Function parseQueryParamSet

coderd/httpapi/queryparams.go:449–466  ·  view source on GitHub ↗
(parser *QueryParamParser, vals url.Values, parse func(set []string) (T, error), def T, queryParam string)

Source from the content-addressed store, hash-verified

447}
448
449func parseQueryParamSet[T any](parser *QueryParamParser, vals url.Values, parse func(set []string) (T, error), def T, queryParam string) (T, error) {
450 parser.addParsed(queryParam)
451 // If the query param is required and not present, return an error.
452 if parser.RequiredNotEmptyParams[queryParam] && (!vals.Has(queryParam) || vals.Get(queryParam) == "") {
453 parser.Errors = append(parser.Errors, codersdk.ValidationError{
454 Field: queryParam,
455 Detail: fmt.Sprintf("Query param %q is required and cannot be empty", queryParam),
456 })
457 return def, nil
458 }
459
460 // If the query param is not present, return the default value.
461 if !vals.Has(queryParam) || vals.Get(queryParam) == "" {
462 return def, nil
463 }
464
465 return parse(vals[queryParam])
466}

Callers 3

ParseCustomListFunction · 0.85
parseNullableQueryParamFunction · 0.85
parseQueryParamFunction · 0.85

Calls 4

addParsedMethod · 0.80
GetMethod · 0.65
parseFunction · 0.50
HasMethod · 0.45

Tested by

no test coverage detected