Documentation
¶
Index ¶
- Constants
- Variables
- func All(_ string, _ any, _ reflect.Value) bool
- func CamelCaseFields(c *Configuration)
- func ExtendsWith(extension ExtensionProvider) func(*Configuration)
- func IncludeEmpty(c *Configuration)
- func IsField(key string, _ any, sv reflect.Value) bool
- func IsNotField(key string, _ any, 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 PascalCaseFields(c *Configuration)
- func RegisterStashFieldFunction(name, sourceKey string, include InclusionPredicate)
- func RegisterUnstashFieldFunction(name, destinationKey string, include InclusionPredicate, ...)
- func UseStashed(stashed, _ any) any
- type Binder
- type Configuration
- type ExtensionProvider
- type InclusionPredicate
- type UnstashConflictResolver
Constants ¶
const ( InKey = "$_gomer_bind_in" OutKey = "$_gomer_bind_out" )
Variables ¶
var ( PascalCaseFn casingFn = func(fieldName string) string { return fieldName } // Exported fields are already PascalCase CamelCaseFn casingFn = func(fieldName string) string { firstChar := fieldName[0] if 'A' <= firstChar && firstChar <= 'Z' { firstChar += 'a' - 'A' } return string(firstChar) + fieldName[1:] } )
Functions ¶
func CamelCaseFields ¶ added in v0.2.0
func CamelCaseFields(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 PascalCaseFields ¶ added in v0.2.0
func PascalCaseFields(c *Configuration)
func RegisterStashFieldFunction ¶
func RegisterStashFieldFunction(name, sourceKey string, include InclusionPredicate)
func RegisterUnstashFieldFunction ¶
func RegisterUnstashFieldFunction(name, destinationKey string, include InclusionPredicate, createIntermediates bool)
func UseStashed ¶
Types ¶
type Binder ¶ added in v0.4.0
Binder holds a configured pair of in/out tools for binding data to and from structs. Create one via NewBinder and pass it explicitly to the components that need it.
func NewBinder ¶ added in v0.4.0
func NewBinder(options ...func(*Configuration)) *Binder
NewBinder creates a Binder with the provided configuration options.
binder := bind.NewBinder(bind.CamelCaseFields, bind.OmitEmpty)
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 ¶
func MergeStashed ¶
func MergeStashed(include InclusionPredicate) UnstashConflictResolver