Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapFieldConfig ¶
type MapFieldConfig struct {
Source string
ExpectedType string
DefaultValue any
Optional bool
Fields map[string]*MapFieldConfig
}
MapFieldConfig lets define the mapping for extracting a map input.
- Source: if set at a level, it will override any field-level sources in the children.
- ExpectedType: if set for a leaf field, the value is converted to that type. For example, "int64", "int", "float64", etc.
type Pickmap ¶
type Pickmap struct {
// contains filtered or unexported fields
}
Pickmap is generic over T which may be a struct or a map.
func NewPickmap ¶
func NewPickmap( urlDecoder URLDecoder, conversionMap map[string]func(any) any, ) *Pickmap
NewPickmap returns a new Pickmap.
Parameters:
- urlDecoder: The URL decoder.
- conversionMap: A map of conversion functions.
Returns:
- *Pickmap: The new Pickmap.
func (*Pickmap) PickMap ¶
PickMap extracts a map[string]any from the request based on the provided MapFieldConfig. It supports both nested and flat extraction. If a source is set at a higher (parent) level, then child fields will use that source.
Parameters:
- r: The HTTP request.
- config: The MapFieldConfig.
Returns:
- map[string]any: The extracted map.
- error: Any error that occurred during processing.
Click to show internal directories.
Click to hide internal directories.