queryparams

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType = errors.New("unknown type")

	// ErrConvertMapStringSlice can not covert to map[string][]string
	ErrConvertMapStringSlice = errors.New("can not convert to map slices of strings")

	// ErrConvertToMapString can not convert to map[string]string
	ErrConvertToMapString = errors.New("can not convert to map of strings")
)

Functions

func Convert

func Convert(obj interface{}) (url.Values, error)

Convert takes an object and converts it to a url.Values object using JSON tags as parameter names. Only top-level simple values, arrays, and slices are serialized. Embedded structs, maps, etc. will not be serialized.

func MapFormJSON

func MapFormJSON(ptr interface{}, form map[string][]string) error

func MapFormWithTag

func MapFormWithTag(ptr interface{}, form map[string][]string, tag string) error

func MapURI

func MapURI(ptr interface{}, m map[string][]string) error

func MappingByPtr

func MappingByPtr(ptr interface{}, setter Setter, tag string) error

Types

type FormSource

type FormSource map[string][]string

func (FormSource) TrySet

func (form FormSource) TrySet(value reflect.Value, field reflect.StructField, tagValue string, opt setOptions) (isSet bool, err error)

TrySet tries to set a value by request's form source (like map[string][]string)

type Marshaler

type Marshaler interface {
	MarshalQueryParameter() (string, error)
}

Marshaler converts an object to a query parameter string representation

type Setter

type Setter interface {
	TrySet(value reflect.Value, field reflect.StructField, key string, opt setOptions) (isSet bool, err error)
}

Setter tries to set value on a walking by fields of a struct

type Unmarshaler

type Unmarshaler interface {
	UnmarshalQueryParameter(string) error
}

Unmarshaler converts a string representation to an object

Jump to

Keyboard shortcuts

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