Documentation
¶
Overview ¶
Package params provides parameter serialization and deserialization functions for OpenAPI-style parameters (simple, form, label, matrix, etc.).
Index ¶
- func BindDeepObjectParam(paramName string, queryParams url.Values, dest any) error
- func BindFormExplodeParam(paramName string, required bool, queryParams url.Values, dest any) error
- func BindFormParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindLabelExplodeParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindLabelParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindMatrixExplodeParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindMatrixParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindPipeDelimitedExplodeParam(paramName string, required bool, queryParams url.Values, dest any) error
- func BindPipeDelimitedParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindSimpleExplodeParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindSimpleParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindSpaceDelimitedExplodeParam(paramName string, required bool, queryParams url.Values, dest any) error
- func BindSpaceDelimitedParam(paramName string, paramLocation ParamLocation, value string, dest any) error
- func BindStringToObject(src string, dst any) error
- func MarshalDeepObject(i any, paramName string) (string, error)
- func StyleDeepObjectParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleFormExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleFormParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleLabelExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleLabelParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleMatrixExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleMatrixParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StylePipeDelimitedExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StylePipeDelimitedParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleSimpleExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleSimpleParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleSpaceDelimitedExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func StyleSpaceDelimitedParam(paramName string, paramLocation ParamLocation, value any) (string, error)
- func UnmarshalDeepObject(dst any, paramName string, params url.Values) error
- type Binder
- type ParamLocation
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindDeepObjectParam ¶
BindDeepObjectParam binds a deepObject-style parameter to a destination. DeepObject style is only valid for query parameters and must be exploded. Objects: ?paramName[key1]=value1¶mName[key2]=value2 -> struct{Key1, Key2} Nested: ?paramName[outer][inner]=value -> struct{Outer: {Inner: value}}
func BindFormExplodeParam ¶
BindFormExplodeParam binds a form-style parameter with explode to a destination. Form style is the default for query and cookie parameters. This handles the exploded case where arrays come as multiple query params. Arrays: ?param=a¶m=b -> []string{"a", "b"} (values passed as slice) Objects: ?key1=value1&key2=value2 -> struct{Key1, Key2} (queryParams passed)
func BindFormParam ¶
func BindFormParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindFormParam binds a form-style parameter without explode to a destination. Form style is the default for query and cookie parameters. This function handles a single query parameter value (not url.Values). Arrays: a,b,c -> []string{"a", "b", "c"} Objects: key1,value1,key2,value2 -> struct{Key1, Key2}
func BindLabelExplodeParam ¶
func BindLabelExplodeParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindLabelExplodeParam binds a label-style parameter with explode to a destination. Label style values are prefixed with a dot. Primitives: .value -> "value" Arrays: .a.b.c -> []string{"a", "b", "c"} Objects: .key1=value1.key2=value2 -> struct{Key1, Key2}
func BindLabelParam ¶
func BindLabelParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindLabelParam binds a label-style parameter without explode to a destination. Label style values are prefixed with a dot. Primitives: .value -> "value" Arrays: .a,b,c -> []string{"a", "b", "c"} Objects: .key1,value1,key2,value2 -> struct{Key1, Key2}
func BindMatrixExplodeParam ¶
func BindMatrixExplodeParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindMatrixExplodeParam binds a matrix-style parameter with explode to a destination. Matrix style values are prefixed with semicolons. Primitives: ;paramName=value -> "value" Arrays: ;paramName=a;paramName=b;paramName=c -> []string{"a", "b", "c"} Objects: ;key1=value1;key2=value2 -> struct{Key1, Key2}
func BindMatrixParam ¶
func BindMatrixParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindMatrixParam binds a matrix-style parameter without explode to a destination. Matrix style values are prefixed with ;paramName=. Primitives: ;paramName=value -> "value" Arrays: ;paramName=a,b,c -> []string{"a", "b", "c"} Objects: ;paramName=key1,value1,key2,value2 -> struct{Key1, Key2}
func BindPipeDelimitedExplodeParam ¶
func BindPipeDelimitedExplodeParam(paramName string, required bool, queryParams url.Values, dest any) error
BindPipeDelimitedExplodeParam binds a pipeDelimited-style parameter with explode. When exploded, arrays come as multiple query params (same as form explode). Arrays: ?param=a¶m=b -> []string{"a", "b"}
func BindPipeDelimitedParam ¶
func BindPipeDelimitedParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindPipeDelimitedParam binds a pipeDelimited-style parameter without explode. Pipe-delimited style uses pipe as the separator. Arrays: a|b|c -> []string{"a", "b", "c"}
func BindSimpleExplodeParam ¶
func BindSimpleExplodeParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindSimpleExplodeParam binds a simple-style parameter with explode to a destination. Simple style is the default for path and header parameters. Arrays: a,b,c -> []string{"a", "b", "c"} (same as non-explode) Objects: key1=value1,key2=value2 -> struct{Key1, Key2}
func BindSimpleParam ¶
func BindSimpleParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindSimpleParam binds a simple-style parameter without explode to a destination. Simple style is the default for path and header parameters. Arrays: a,b,c -> []string{"a", "b", "c"} Objects: key1,value1,key2,value2 -> struct{Key1, Key2}
func BindSpaceDelimitedExplodeParam ¶
func BindSpaceDelimitedExplodeParam(paramName string, required bool, queryParams url.Values, dest any) error
BindSpaceDelimitedExplodeParam binds a spaceDelimited-style parameter with explode. When exploded, arrays come as multiple query params (same as form explode). Arrays: ?param=a¶m=b -> []string{"a", "b"}
func BindSpaceDelimitedParam ¶
func BindSpaceDelimitedParam(paramName string, paramLocation ParamLocation, value string, dest any) error
BindSpaceDelimitedParam binds a spaceDelimited-style parameter without explode. Space-delimited style uses space as the separator. Arrays: a b c -> []string{"a", "b", "c"}
func BindStringToObject ¶
BindStringToObject binds a string value to a destination object. It handles primitives, encoding.TextUnmarshaler, and the Binder interface.
func MarshalDeepObject ¶
MarshalDeepObject marshals an object to deepObject style query parameters.
func StyleDeepObjectParam ¶
func StyleDeepObjectParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleDeepObjectParam serializes a value using deepObject style. DeepObject style is only valid for query parameters with object values and must be exploded. Objects: paramName[key1]=value1¶mName[key2]=value2 Nested: paramName[outer][inner]=value
func StyleFormExplodeParam ¶
func StyleFormExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleFormExplodeParam serializes a value using form style (RFC 6570) with exploding. Form style is the default for query and cookie parameters. Primitives: paramName=value Arrays: paramName=a¶mName=b¶mName=c Objects: key1=value1&key2=value2
func StyleFormParam ¶
func StyleFormParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleFormParam serializes a value using form style (RFC 6570) without exploding. Form style is the default for query and cookie parameters. Primitives: paramName=value Arrays: paramName=a,b,c Objects: paramName=key1,value1,key2,value2
func StyleLabelExplodeParam ¶
func StyleLabelExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleLabelExplodeParam serializes a value using label style (RFC 6570) with exploding. Label style prefixes values with a dot. Primitives: .value Arrays: .a.b.c Objects: .key1=value1.key2=value2
func StyleLabelParam ¶
func StyleLabelParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleLabelParam serializes a value using label style (RFC 6570) without exploding. Label style prefixes values with a dot. Primitives: .value Arrays: .a,b,c Objects: .key1,value1,key2,value2
func StyleMatrixExplodeParam ¶
func StyleMatrixExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleMatrixExplodeParam serializes a value using matrix style (RFC 6570) with exploding. Matrix style prefixes values with ;paramName=. Primitives: ;paramName=value Arrays: ;paramName=a;paramName=b;paramName=c Objects: ;key1=value1;key2=value2
func StyleMatrixParam ¶
func StyleMatrixParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleMatrixParam serializes a value using matrix style (RFC 6570) without exploding. Matrix style prefixes values with ;paramName=. Primitives: ;paramName=value Arrays: ;paramName=a,b,c Objects: ;paramName=key1,value1,key2,value2
func StylePipeDelimitedExplodeParam ¶
func StylePipeDelimitedExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StylePipeDelimitedExplodeParam serializes a value using pipeDelimited style with exploding. Pipe-delimited style is used for query parameters with array values. Arrays: paramName=a¶mName=b¶mName=c (same as form explode) Note: Only valid for arrays; objects should use other styles.
func StylePipeDelimitedParam ¶
func StylePipeDelimitedParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StylePipeDelimitedParam serializes a value using pipeDelimited style without exploding. Pipe-delimited style is used for query parameters with array values. Arrays: paramName=a|b|c Note: Only valid for arrays; objects should use other styles.
func StyleSimpleExplodeParam ¶
func StyleSimpleExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleSimpleExplodeParam serializes a value using simple style (RFC 6570) with exploding. Simple style is the default for path and header parameters. Arrays are comma-separated: a,b,c (same as non-explode) Objects are key=value pairs: key1=value1,key2=value2
func StyleSimpleParam ¶
func StyleSimpleParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleSimpleParam serializes a value using simple style (RFC 6570) without exploding. Simple style is the default for path and header parameters. Arrays are comma-separated: a,b,c Objects are key,value pairs: key1,value1,key2,value2
func StyleSpaceDelimitedExplodeParam ¶
func StyleSpaceDelimitedExplodeParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleSpaceDelimitedExplodeParam serializes a value using spaceDelimited style with exploding. Space-delimited style is used for query parameters with array values. Arrays: paramName=a¶mName=b¶mName=c (same as form explode) Note: Only valid for arrays; objects should use other styles.
func StyleSpaceDelimitedParam ¶
func StyleSpaceDelimitedParam(paramName string, paramLocation ParamLocation, value any) (string, error)
StyleSpaceDelimitedParam serializes a value using spaceDelimited style without exploding. Space-delimited style is used for query parameters with array values. Arrays: paramName=a b c (space-separated) Note: Only valid for arrays; objects should use other styles.
Types ¶
type ParamLocation ¶
type ParamLocation int
ParamLocation indicates where a parameter is located in an HTTP request.
const ( ParamLocationUndefined ParamLocation = iota ParamLocationQuery ParamLocationPath ParamLocationHeader ParamLocationCookie )