Documentation ¶
Overview ¶
Package queryparam provides a query parameter parser.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FieldParams ¶
type FieldParams struct { OwnKey string Key string DefaultValue []string HasDefaultValue bool Dive bool }
FieldParams contains information about parsed field tags.
type NoParserError ¶
NoParserError occurs when there is no parser provided for given type
type NoSupportedTagOptionError ¶
type NoSupportedTagOptionError struct {
Tag string
}
NoSupportedTagOptionError occurs when the given tag is not supported In-built supported tags: "", "required", "unset", "notEmpty", "expand", "paramDefault"
func (NoSupportedTagOptionError) Error ¶
func (e NoSupportedTagOptionError) Error() string
Error returns the error message.
type NotStructPtrError ¶
type NotStructPtrError struct{}
NotStructPtrError occurs when pass something that is not a pointer to a Struct to Parse
func (NotStructPtrError) Error ¶
func (e NotStructPtrError) Error() string
Error returns the error message.
type Options ¶
type Options struct { // Param keys and values that will be accessible for the service. Param map[string][]string // DefaultValueSeparator for slice values. DefaultValueSeparator string // TagName specifies another tagname to use rather than the default queryParam. TagName string // RequiredIfNoDef automatically sets all param as required if they do not // declare 'paramDefault'. RequiredIfNoDef bool // OnSet allows to run a function when a value is set. OnSet OnSetFn // Prefix define a prefix for each key. Prefix string // UseFieldNameByDefault defines whether or not param should use the field // name by default if the `queryParam` key is missing. // Note that the field name will be "converted" to conform with param // names conventions. UseFieldNameByDefault bool // Custom parse functions for different types. FuncMap map[reflect.Type]ParserFunc // contains filtered or unexported fields }
Options for the parser.
type ParseError ¶
ParseError occurs when it's impossible to convert the value for given type.
type Parser ¶
Parser is a struct that can be used to parse query params.
func (*Parser) GetFieldParams ¶
func (p *Parser) GetFieldParams(v any) ([]FieldParams, error)
GetFieldParams parses a struct containing `queryParam` tags and returns information about tags it found.
func (*Parser) GetFieldParamsWithOptions ¶
func (p *Parser) GetFieldParamsWithOptions(v any, opts Options) ([]FieldParams, error)
GetFieldParamsWithOptions parses a struct containing `queryParam` tags and returns information about tags it found.
type ParserFunc ¶
ParserFunc defines the signature of a function that can be used within `CustomParsers`.