params

package
v0.0.0-...-664df8a Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package params defines different types of params used for changeset input.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Form

type Form map[string][]interface{}

Form is param type alias for url.Values

func ParseForm

func ParseForm(raw url.Values) Form

ParseForm form from url values.

func (Form) Exists

func (form Form) Exists(name string) bool

Exists returns true if key exists.

func (Form) Get

func (form Form) Get(name string) interface{}

Get returns value as interface. returns nil if value doens't exists. the value returned is slice of interface{}

func (Form) GetParams

func (form Form) GetParams(name string) (Params, bool)

GetParams returns nested param

func (Form) GetParamsSlice

func (form Form) GetParamsSlice(name string) ([]Params, bool)

GetParamsSlice returns slice of nested param

func (Form) GetWithType

func (form Form) GetWithType(name string, typ reflect.Type) (interface{}, bool)

GetWithType returns value given from given name and type. second return value will only be false if the type of parameter is not convertible to requested type. If value is not convertible to type, it'll return nil, false If value is not exists, it will return nil, true

type JSON

type JSON struct {
	gjson.Result
	// contains filtered or unexported fields
}

JSON is param type for json document.

func (*JSON) Exists

func (json *JSON) Exists(name string) bool

Exists returns true if key exists.

func (*JSON) Get

func (json *JSON) Get(name string) interface{}

Get returns value as interface. returns nil if value doens't exists.

func (*JSON) GetParams

func (json *JSON) GetParams(name string) (Params, bool)

GetParams returns nested param

func (*JSON) GetParamsSlice

func (json *JSON) GetParamsSlice(name string) ([]Params, bool)

GetParamsSlice returns slice of nested param

func (*JSON) GetWithType

func (json *JSON) GetWithType(name string, typ reflect.Type) (interface{}, bool)

GetWithType returns value given from given name and type. second return value will only be false if the type of parameter is not convertible to requested type. If value is not convertible to type, it'll return nil, false If value is not exists, it will return nil, true

type Map

type Map map[string]interface{}

Map is param type alias for map[string]interface{}

func (Map) Exists

func (m Map) Exists(name string) bool

Exists returns true if key exists.

func (Map) Get

func (m Map) Get(name string) interface{}

Get returns value as interface. returns nil if value doens't exists.

func (Map) GetParams

func (m Map) GetParams(name string) (Params, bool)

GetParams returns nested param

func (Map) GetParamsSlice

func (m Map) GetParamsSlice(name string) ([]Params, bool)

GetParamsSlice returns slice of nested param

func (Map) GetWithType

func (m Map) GetWithType(name string, typ reflect.Type) (interface{}, bool)

GetWithType returns value given from given name and type. second return value will only be false if the type of parameter is not convertible to requested type. If value is not convertible to type, it'll return nil, false If value is not exists, it will return nil, true

type Params

type Params interface {
	Exists(name string) bool
	Get(name string) interface{}
	GetWithType(name string, typ reflect.Type) (interface{}, bool)
	GetParams(name string) (Params, bool)
	GetParamsSlice(name string) ([]Params, bool)
}

Params is interface used by changeset when casting parameters to changeset.

func ParseJSON

func ParseJSON(json string) Params

ParseJSON as params

Jump to

Keyboard shortcuts

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