Documentation ¶
Index ¶
- type Context
- func (c Context) Apply(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) 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) 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) 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) Get ¶
Get returns the given key's value as an interface{} and returns nil if not found. Get looks for the key as given first and if not found looks for a CamelCased version of the key and if still not found looks for a kebab-ified version, finally if nothing is found, nil is returned.
func (Context) Keys ¶
Keys returns a list of all the map keys in the Context, sorted in natural order for consistency
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