Documentation
¶
Index ¶
- Constants
- func DeepEqual(v1, v2 any) bool
- func Rest[T any](s []T) []T
- type GetterPlugin
- type Setter
- func (s *Setter) Get(root, data, expression any) any
- func (s *Setter) GetByRouter(root any, data any, routers []string, param []any) any
- func (s *Setter) GetBySlice(root, data any, expressions []any) any
- func (s *Setter) GetPluginName(name string) string
- func (s *Setter) GetSegmentation() string
- func (s *Setter) Set(src any, dst any, phases []map[string]any) (any, map[string]any)
- func (s *Setter) SetByRouter(dst any, router []string, data any) any
- func (s *Setter) SetDefaultPhases(phases []map[string]any)
- func (s *Setter) SetForArray(forArray bool)
- func (s *Setter) SetGetterPlugins(plugins []GetterPlugin)
- func (s *Setter) SetOmitempty(omitempty bool)
- func (s *Setter) SetPluginPrefix(prefix string)
- func (s *Setter) SetRedirectSrc(redirectSrc bool)
- func (s *Setter) SetSegmentation(segmentation string)
- func (s *Setter) SetSetterPlugins(plugins []SetterPlugin)
- func (s *Setter) Verify(phases []map[string]any) error
- type SetterPlugin
Constants ¶
const ( Router = "router" Literal = "literal" Mode = "mode" This = "this" Array = "array" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GetterPlugin ¶
type GetterPlugin interface {
Exec(s *Setter, root, data any, expression []string, param []any) any
Verify(param []any) ([]any, error)
Name() string
}
GetterPlugin execute when a router string is equal to result of Name()
type Setter ¶
type Setter struct {
// contains filtered or unexported fields
}
Setter provide method 'set' and 'get'
func (*Setter) GetByRouter ¶
GetByRouter get value by routers and param.
func (*Setter) GetBySlice ¶
GetBySlice get value by expressions first element of expressions is declared as router. rest elements are declared as params.
func (*Setter) GetPluginName ¶
GetPluginName return plugin name with prefix
func (*Setter) GetSegmentation ¶
GetSegmentation return segmentation
func (*Setter) Set ¶
Set dst by phases and data of src. Return new value of dst and info of plugins return. The origin dst may be changed. The correct way to use it is -- dst,info = s.Set(src,dst,phases)
func (*Setter) SetByRouter ¶
SetByRouter set value of dst by router and data of src
func (*Setter) SetDefaultPhases ¶
SetDefaultPhases defaultPhases is used in Set when phases is nil
func (*Setter) SetForArray ¶
SetForArray traverse array to get value by rest of routers when meet an array in GetByRouter.
Logic of forArray is as same as plugin 'for'. Set forArray to true allowed you to omit router 'for' in routers. On the other hand it makes the mean of router ambiguous.
func (*Setter) SetGetterPlugins ¶
func (s *Setter) SetGetterPlugins(plugins []GetterPlugin)
SetGetterPlugins set getter plugins of setter
func (*Setter) SetOmitempty ¶
SetOmitempty delete null value in map[string]any if omitempty is true
func (*Setter) SetPluginPrefix ¶
SetPluginPrefix plugin prefix is a string to mark a router string is a pointer to a plugin. Works in both setter and getter.
func (*Setter) SetRedirectSrc ¶
SetRedirectSrc set src to dst while a phase finished in Set
func (*Setter) SetSegmentation ¶
SetSegmentation segmentation is a string to split routers. Works in both setter and getter.
func (*Setter) SetSetterPlugins ¶
func (s *Setter) SetSetterPlugins(plugins []SetterPlugin)
SetSetterPlugins set setter plugins of setter