xparam

package module
v0.0.0-...-bc6bf63 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

README

xparam

Abstraction for map[string]interface{}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DurationToString

func DurationToString(dt time.Duration) string

Converts duration into string notation, ie: 1d, 1h, 1m The smallest interval is 1m. Smaller values replaced with 1m.

func StringToDuration

func StringToDuration(val string) (dt time.Duration, err error)

Converts string into duration, ie: 1d, 1h, 1m 30d, 77h, 99m

Types

type XP

type XP map[string]interface{}

func New

func New(vals map[string]interface{}) XP

func New_FromMetaData

func New_FromMetaData(meta, data map[string]string) (xp XP, err error)

Creates new XP from supplied data and its metadata.

func (XP) As_ArrayDuration

func (xp XP) As_ArrayDuration(key string) (data []time.Duration)

Gets parameter as time.Duration array.

func (XP) As_ArrayFloat64

func (xp XP) As_ArrayFloat64(key string) (data []float64)

Gets parameter as float64 array.

func (XP) As_ArrayInt

func (xp XP) As_ArrayInt(key string) (data []int)

Gets parameter as int array.

func (XP) As_ArrayMapString

func (xp XP) As_ArrayMapString(key string, fields ...string) (data []map[string]string)

Gets parameter as array of string maps.

func (XP) As_ArrayString

func (xp XP) As_ArrayString(key string) (data []string)

Gets parameter as string array.

func (XP) As_ArrayXP

func (xp XP) As_ArrayXP(key string) (data []XP)

Gets parameter as array of xparams.

func (XP) As_Bool

func (xp XP) As_Bool(key string) (b bool)

Gets parameter as bool. Can be either pure JSON bool or "true" string. All other stings including empty will be treated as false.

func (XP) As_Float64

func (xp XP) As_Float64(key string) (f float64)

Gets parameter as float64.

func (XP) As_Int

func (xp XP) As_Int(key string) (n int)

Gets parameter as int.

func (XP) As_Int64

func (xp XP) As_Int64(key string) (n int64)

Gets parameter as int64.

func (XP) As_MapInt

func (xp XP) As_MapInt(key string) (data map[string]int64)

Gets parameter as map of string to integers.

func (XP) As_MapString

func (xp XP) As_MapString(key string) (data map[string]string)

Gets parameter as map of string to sting.

func (XP) As_ObjectId

func (xp XP) As_ObjectId(key string) (id *bson.ObjectId)

Gets key value as if it should be bson.ObjectId.

func (XP) As_String

func (xp XP) As_String(key string) (str string)

Gets parameter as string (trimmed).

func (XP) As_StringEmail

func (xp XP) As_StringEmail(key string) string

Gets parameter as email address string (trimmed & lower cased).

func (XP) As_StringNil

func (xp XP) As_StringNil(key string) (str *string)

Gets parameter as string pointer allowing for the nil option.

func (XP) As_Time

func (xp XP) As_Time(key string) (t time.Time)

Gets parameter as time. Call t.IsZero() to check for error. IMPORTANT: correct time format is "2014-11-19T00:00:00-08:00" for a specific time zone, or "2006-01-02T15:04:05Z" for UTC. See http://www.ietf.org/rfc/rfc3339.txt

func (XP) As_TimeDuration

func (xp XP) As_TimeDuration(key string) (d time.Duration)

Gets parameter as time duration.

func (XP) As_XP

func (xp XP) As_XP(key string) (data XP)

Gets parameter as array of xparams.

func (XP) Get_HttpRequest

func (xp XP) Get_HttpRequest() (req *http.Request)

Gets http.Request.

func (XP) Get_HttpResponseWriter

func (xp XP) Get_HttpResponseWriter() (rw http.ResponseWriter)

Gets http.ResponseWriter.

func (XP) Get_SessionValues

func (xp XP) Get_SessionValues() (vals map[string]string)

Gets session values.

func (XP) MustBe_ObjectId

func (xp XP) MustBe_ObjectId(key string) (id bson.ObjectId, err error)

Gets key value as bson.ObjectId.

func (XP) To_String

func (xp XP) To_String(to *map[string]string, key string)

Sets parameter as string.

Jump to

Keyboard shortcuts

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