querymap

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2025 License: LGPL-3.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromURLStringToStruct

func FromURLStringToStruct[T any](URL string) (*T, error)

FromURLStringToStruct is an additional wrapper that parses the URL string, and then calls FromURLToStruct.

func FromURLToStruct

func FromURLToStruct[T any](URL *url.URL) (*T, error)

FromURLToStruct is a convenient function that combines FromURL and ToStruct. Accepts *url.URL and tries to convert the query string into a T structure.

func FromValuesToStruct added in v1.0.1

func FromValuesToStruct[T any](values url.Values) (*T, error)

FromValuesToStruct is a convenient function that combines FromValues and ToStruct. Accepts url.Values and tries to convert the query string into a T structure.

func NormalizeSlicesNumbersIndexes

func NormalizeSlicesNumbersIndexes(v any) any

NormalizeSlicesNumbersIndexes recursively checks whether the value is a set of numeric keys, and if so, converts it to a slice (anyList). For example, QueryMap{"0": "first", "1": "second"} => []any{"first", "second"}.

func ToStruct

func ToStruct[T any](m QueryMap) (*T, error)

ToStruct converts QueryMap into a structure of type T using mapstructure. The fields of the structure are read by the `json` tag.

Types

type QueryMap

type QueryMap map[string]any

QueryMap is a map storing key-values from query-parameters. The value can be of one of the following types: string, []string, QueryMap, anyList.

func FromURL

func FromURL(URL *url.URL) QueryMap

FromURL parses the *url.URL object and returns a QueryMap representing all its query parameters as a nested structure.

func FromValues added in v1.0.1

func FromValues(urlQuery url.Values) QueryMap

FromValues parses the url.Values object and returns a QueryMap representing all its query parameters as a nested structure.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL