bind

package
v0.0.0-...-8f66fda Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InKey  = "$_gomer_bind_in"
	OutKey = "$_gomer_bind_out"
)

Variables

View Source
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:]
	}
)

Functions

func All

func All(_ string, _ interface{}, _ reflect.Value) bool

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 In

func In(data map[string]interface{}, v interface{}, inTool *structs.Tool, optional ...*structs.ToolContext) gomerr.Gomerr

func IncludeEmpty

func IncludeEmpty(c *Configuration)

func IsField

func IsField(key string, _ interface{}, sv reflect.Value) bool

func IsNotField

func IsNotField(key string, _ interface{}, sv reflect.Value) bool

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 Out

func Out(v interface{}, outTool *structs.Tool, optional ...*structs.ToolContext) (map[string]interface{}, gomerr.Gomerr)

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

type InclusionPredicate func(key string, value interface{}, sv reflect.Value) bool

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

Jump to

Keyboard shortcuts

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