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

Function ParseCustom

coderd/httpapi/queryparams.go:355–364  ·  view source on GitHub ↗

ParseCustom has to be a function, not a method on QueryParamParser because generics cannot be used on struct methods.

(parser *QueryParamParser, vals url.Values, def T, queryParam string, parseFunc func(v string) (T, error))

Source from the content-addressed store, hash-verified

353// ParseCustom has to be a function, not a method on QueryParamParser because generics
354// cannot be used on struct methods.
355func ParseCustom[T any](parser *QueryParamParser, vals url.Values, def T, queryParam string, parseFunc func(v string) (T, error)) T {
356 v, err := parseQueryParam(parser, vals, parseFunc, def, queryParam)
357 if err != nil {
358 parser.Errors = append(parser.Errors, codersdk.ValidationError{
359 Field: queryParam,
360 Detail: fmt.Sprintf("Query param %q has invalid value: %s", queryParam, err.Error()),
361 })
362 }
363 return v
364}
365
366// ParseCustomList is a function that handles csv query params or multiple values
367// for a query param.

Callers 11

TestParseQueryParamsFunction · 0.92
extractAuthorizeParamsFunction · 0.92
extractTokenRequestFunction · 0.92
AuditLogsFunction · 0.92
ConnectionLogsFunction · 0.92
WorkspacesFunction · 0.92
parseOrganizationFunction · 0.92
parseUserFunction · 0.92
parseGroupFunction · 0.92
UUIDorNameMethod · 0.85
UUIDorMeMethod · 0.85

Calls 2

parseQueryParamFunction · 0.85
ErrorMethod · 0.45

Tested by 1

TestParseQueryParamsFunction · 0.74