Documentation ¶
Index ¶
- Constants
- Variables
- func All(_ string, _ interface{}, _ reflect.Value) bool
- func CamelCaseData(c *Configuration)
- func EmptyDirectiveIncludesField(c *Configuration)
- func EmptyDirectiveSkipsField(c *Configuration)
- func ExtendsWith(extension ExtensionProvider) func(*Configuration)
- func In(data map[string]interface{}, v interface{}, inTool *structs.Tool, ...) gomerr.Gomerr
- func IncludeEmpty(c *Configuration)
- func IsField(key string, _ interface{}, sv reflect.Value) bool
- func IsNotField(key string, _ interface{}, sv reflect.Value) bool
- func NewInTool(bindConfig Configuration, dp structs.DirectiveProvider) *structs.Tool
- func NewOutTool(bindConfig Configuration, dp structs.DirectiveProvider) *structs.Tool
- func OmitEmpty(c *Configuration)
- func Out(v interface{}, outTool *structs.Tool, optional ...*structs.ToolContext) (map[string]interface{}, gomerr.Gomerr)
- func PascalCaseData(c *Configuration)
- func RegisterStashFieldFunction(name, sourceKey string, include InclusionPredicate)
- func RegisterUnstashFieldFunction(name, destinationKey string, include InclusionPredicate, ...)
- func UseStashed(stashed, _ interface{}) interface{}
- type Configuration
- type ExtensionProvider
- type InclusionPredicate
- type UnstashConflictResolver
Constants ¶
const ( InKey = "$_gomer_bind_in" OutKey = "$_gomer_bind_out" )
Variables ¶
var ( PascalCase casingFn = func(fieldName string) string { return fieldName } // Exported fields are already PascalCase CamelCase casingFn = func(fieldName string) string { firstChar := fieldName[0] if 'A' <= firstChar && firstChar <= 'Z' { firstChar += 'a' - 'A' } return string(firstChar) + fieldName[1:] } )
var DefaultInTool = NewInTool(NewConfiguration(), structs.StructTagDirectiveProvider{"in"})
var DefaultOutTool = NewOutTool(NewConfiguration(), structs.StructTagDirectiveProvider{"out"})
Functions ¶
func CamelCaseData ¶
func CamelCaseData(c *Configuration)
func EmptyDirectiveIncludesField ¶
func EmptyDirectiveIncludesField(c *Configuration)
func EmptyDirectiveSkipsField ¶
func EmptyDirectiveSkipsField(c *Configuration)
func ExtendsWith ¶
func ExtendsWith(extension ExtensionProvider) func(*Configuration)
func IncludeEmpty ¶
func IncludeEmpty(c *Configuration)
func NewInTool ¶
func NewInTool(bindConfig Configuration, dp structs.DirectiveProvider) *structs.Tool
NewInTool
<name> -> Default input value matching <name>. If name == "" then name = b.DataCase(StructField.Name) =<static> -> Application-defined static value $<function> -> Application-defined dynamic value ?<directive> -> Applied iff field.IsZero(). Supports chaining (e.g. "query.aName?header.A-Source?=aDefault") <directive>&<right> -> Applies the left directive followed by the right (e.g. "input&$transform) <directive>!<right> -> Applies the left directive and, if it succeeds, the right - -> Explicitly not bound from any input
func NewOutTool ¶
func NewOutTool(bindConfig Configuration, dp structs.DirectiveProvider) *structs.Tool
NewOutTool
+ -> Use field name as value's key. Required if EmptyDirectiveHandling == skipField <name> -> Use 'name' as value's key (if PayloadBindingPrefix != "", form is similar to header) =<static> -> Static output value $<function> -> Function-derived output value ?<directive> -> Applied iff field.IsZero(). Supports chaining (e.g. "?$foo?=last") <directive>&<right> -> Will apply the left directive followed by the right (e.g. "=OutValue&header.X-My-Header) <directive>!<right> -> Applies the left directive and, if it succeeds, the right - -> Explicitly not included in the output
Except for '-', each of the above can be combined with an ",omitempty" or ",includempty" qualifier that acts like '-' or '+' respectively if the field's value is its zero Value.
func OmitEmpty ¶
func OmitEmpty(c *Configuration)
func PascalCaseData ¶
func PascalCaseData(c *Configuration)
func RegisterStashFieldFunction ¶
func RegisterStashFieldFunction(name, sourceKey string, include InclusionPredicate)
func RegisterUnstashFieldFunction ¶
func RegisterUnstashFieldFunction(name, destinationKey string, include InclusionPredicate, createIntermediates bool)
func UseStashed ¶
func UseStashed(stashed, _ interface{}) interface{}
Types ¶
type Configuration ¶
type Configuration struct {
// contains filtered or unexported fields
}
func CopyConfigurationWithOptions ¶
func CopyConfigurationWithOptions(b Configuration, options ...func(*Configuration)) Configuration
func NewConfiguration ¶
func NewConfiguration(options ...func(*Configuration)) Configuration
type ExtensionProvider ¶
type ExtensionProvider interface { structs.ApplierProvider Type() string }
type InclusionPredicate ¶
func IfAll ¶
func IfAll(predicates ...InclusionPredicate) InclusionPredicate
func IfAny ¶
func IfAny(predicates ...InclusionPredicate) InclusionPredicate
func NameMatches ¶
func NameMatches(names ...string) InclusionPredicate
type UnstashConflictResolver ¶
type UnstashConflictResolver func(stashed, destination interface{}) interface{}
func MergeStashed ¶
func MergeStashed(include InclusionPredicate) UnstashConflictResolver