Documentation ¶
Index ¶
- type Context
- func (c Context) Apply(contexts ...Context)
- func (c Context) ApplySpecific(contexts ...Context)
- func (c Context) AsJSON() (data []byte, err error)
- func (c Context) AsMap() (out map[string]interface{})
- func (c Context) AsMapStrings() (out map[string]string)
- func (c Context) AsOsEnviron() (out []string)
- func (c Context) AsTOML() (data []byte, err error)
- func (c Context) AsYAML() (data []byte, err error)
- func (c Context) Bool(key string, def bool) bool
- func (c Context) CamelizeKeys()
- func (c Context) Copy() (ctx Context)
- func (c Context) DefaultStrings(key string, def []string) []string
- func (c Context) Delete(key string) (deleted bool)
- func (c Context) DeleteKeys(keys ...string)
- func (c Context) Float64(key string, def float64) float64
- func (c Context) Get(key string) (value interface{})
- func (c Context) GetKV(key string) (k string, v interface{})
- func (c Context) Has(key string) (present bool)
- func (c Context) Int(key string, def int) int
- func (c Context) Int64(key string, def int64) int64
- func (c Context) Keys() (keys []string)
- func (c Context) LowerCamelizeKeys()
- func (c Context) Select(keys ...string) (selected map[string]interface{})
- func (c Context) Set(key string, value interface{}) Context
- func (c Context) SetSpecific(key string, value interface{}) Context
- func (c Context) String(key, def string) string
- func (c Context) StringOrStrings(key string) (values []string)
- func (c Context) Strings(key string) (values []string)
- func (c Context) Uint(key string, def uint) uint
- func (c Context) Uint64(key string, def uint64) uint64
- func (c Context) ValueAsInt(key string, def int) int
- type RequestKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context map[string]interface{}
Context is a wrapper around a map[string]interface{} structure which is used throughout Go-Enjin for parsing configurations and contents.
func NewFromMap ¶
NewFromMap casts an existing map[string]interface{} as a Context
func NewFromOsEnviron ¶
NewFromOsEnviron constructs a new Context from os.Environ() string K=V slices
func (Context) ApplySpecific ¶ added in v0.2.2
ApplySpecific takes a list of contexts and merges their contents into this one, keeping the keys specifically
func (Context) AsMap ¶
AsMap returns this Context, shallowly copied, as a new map[string]interface{} instance.
func (Context) AsMapStrings ¶
AsMapStrings returns this Context as a transformed map[string]string structure, where each key's value is checked and if it's a string, use it as-is and if it's anything else, run it through fmt.Sprintf("%v") to make it a string.
func (Context) AsOsEnviron ¶
AsOsEnviron returns this Context as a transformed []string slice where each key is converted to SCREAMING_SNAKE_CASE and the value is converted to a string (similarly to AsMapStrings) and the key/value pair is concatenated into a single "K=V" string and appended to the output slice, sorted by key in natural order, suitable for use in os.Environ cases.
func (Context) CamelizeKeys ¶
func (c Context) CamelizeKeys()
CamelizeKeys transforms all keys within the Context to be of CamelCased form
func (Context) DefaultStrings ¶
DefaultStrings is a wrapper around Strings() and returns the given default list of strings if the key is not found
func (Context) Delete ¶
Delete deletes the given key from the Context and follows a similar key lookup process to Get() for finding the key to delete and will only delete the first matching key format (specific, Camel, kebab) found
func (Context) DeleteKeys ¶
DeleteKeys is a batch wrapper around Delete()
func (Context) GetKV ¶ added in v0.2.2
GetKV looks for the key as given first and if not found looks for CamelCased, kebab-case and snake_cased variations; returning the actual key found and the generic value; returns an empty key and nil value if nothing found at all
func (Context) Keys ¶
Keys returns a list of all the map keys in the Context, sorted in natural order for consistency
func (Context) LowerCamelizeKeys ¶ added in v0.2.2
func (c Context) LowerCamelizeKeys()
LowerCamelizeKeys transforms all keys within the Context to be of lowerCamelCased form
func (Context) SetSpecific ¶
SetSpecific is like Set(), without CamelCasing the key
func (Context) String ¶
String returns the key's value as a string, returning the given default if not found or not actually a string value.
func (Context) StringOrStrings ¶
StringOrStrings returns the key's value as a list of strings and if the key's actual value is not a list of strings, return that as a list of one string
type RequestKey ¶
type RequestKey string