Documentation
¶
Index ¶
- func BindParameter(paramName string, value string, dest any, opts ParameterOptions) error
- func BindQueryParameter(paramName string, queryParams url.Values, dest any, opts ParameterOptions) error
- func BindRawQueryParameter(paramName string, rawQuery string, dest any, opts ParameterOptions) error
- func BindStringToObject(src string, dst any) error
- func MarshalDeepObject(i any, paramName string) (string, error)
- func StyleParameter(paramName string, value any, opts ParameterOptions) (string, error)
- func UnmarshalDeepObject(dst any, paramName string, params url.Values) error
- type Binder
- type MissingRequiredParameterError
- type ParamLocation
- type ParameterOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindParameter ¶
func BindParameter(paramName string, value string, dest any, opts ParameterOptions) error
BindParameter binds a styled parameter from a single string value to a Go object. This is the entry point for path, header, and cookie parameters where the HTTP framework has already extracted the raw value.
The Style field in opts selects how the value is split into parts (simple, label, matrix, form). If Style is empty, "simple" is assumed.
func BindQueryParameter ¶
func BindQueryParameter(paramName string, queryParams url.Values, dest any, opts ParameterOptions) error
BindQueryParameter binds a query parameter from pre-parsed url.Values. The Style field in opts selects parsing behavior. If Style is empty, "form" is assumed. Supports form, spaceDelimited, pipeDelimited, and deepObject.
func BindRawQueryParameter ¶
func BindRawQueryParameter(paramName string, rawQuery string, dest any, opts ParameterOptions) error
BindRawQueryParameter works like BindQueryParameter but operates on the raw (undecoded) query string. This correctly handles form/explode=false parameters whose values contain literal commas encoded as %2C — something that BindQueryParameter cannot do because url.Values has already decoded %2C to ',' before we can split on the delimiter comma.
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 StyleParameter ¶
func StyleParameter(paramName string, value any, opts ParameterOptions) (string, error)
StyleParameter serializes a Go value into an OpenAPI-styled parameter string. This is the entry point for client-side parameter serialization. The Style field in opts selects the serialization format. If Style is empty, "simple" is assumed.
Types ¶
type MissingRequiredParameterError ¶
type MissingRequiredParameterError struct {
ParamName string
}
MissingRequiredParameterError is returned when a required parameter is not present in the request. Upper layers can use errors.As to detect this and produce an appropriate HTTP error response.
func (*MissingRequiredParameterError) Error ¶
func (e *MissingRequiredParameterError) Error() string
type ParamLocation ¶
type ParamLocation int
ParamLocation indicates where a parameter is located in an HTTP request.
const ( ParamLocationUndefined ParamLocation = iota ParamLocationQuery ParamLocationPath ParamLocationHeader ParamLocationCookie )
type ParameterOptions ¶
type ParameterOptions struct {
Style string // OpenAPI style: "simple", "form", "label", "matrix", "deepObject", "pipeDelimited", "spaceDelimited"
ParamLocation ParamLocation // Where the parameter appears: query, path, header, cookie
Explode bool
Required bool
Type string // OpenAPI type: "string", "integer", "array", "object"
Format string // OpenAPI format: "int32", "date-time", etc.
AllowReserved bool // When true, reserved characters in query values are not percent-encoded
}
ParameterOptions carries OpenAPI parameter metadata to bind and style functions so they can handle style dispatch, explode, required, type-aware coercions, and location-aware escaping from a single uniform call site. All fields have sensible zero-value defaults.