Documentation ¶
Index ¶
- func Add(groupName string, ruleName string, rule Rule) error
- func AddChild(groupName string, ruleName string, parentRuleName string, rule Rule) error
- func AddRequiredInput(groupName string, inputName string, it InputType)
- func HandleRuleGroup(w http.ResponseWriter, r *http.Request)
- func Process(groupName string, input map[string]interface{}, options ProcessOptions) (map[string]interface{}, error)
- func SetDefaultFlatten(groupName string, value bool)
- func SetDefaultKeepFirst(groupName string, value bool)
- func SetRequestFilter(rf RequestFilter)
- func SetResponseFilter(rf ResponseFilter)
- func StartServer() error
- type Context
- type InputType
- type ProcessOptions
- type RequestFilter
- type ResponseFilter
- type Rule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRequiredInput ¶
AddRequiredInput adds a input attribute name that is required before processing the rules
func HandleRuleGroup ¶ added in v1.0.1
func HandleRuleGroup(w http.ResponseWriter, r *http.Request)
func Process ¶
func Process(groupName string, input map[string]interface{}, options ProcessOptions) (map[string]interface{}, error)
Process process all rules in a group and return a resulting map with all values returned by the rules
func SetDefaultFlatten ¶
SetDefaultFlatten sets whatever to flatten output or keep it hierarchical. This may be overriden during rules evaluation with a "_flatten" attribute in input
func SetDefaultKeepFirst ¶
SetDefaultKeepFirst sets whatever to keep the first or the last occurence of an output attribute when flattening the output. This may be overriden during rules evaluation with a "_keepFirst" attribute in input
func SetRequestFilter ¶
func SetRequestFilter(rf RequestFilter)
SetRequestFilter set the function that will be called at every call
func SetResponseFilter ¶
func SetResponseFilter(rf ResponseFilter)
SetResponseFilter set the function that will be called at every call with output. If returns true, won't perform the default JSON renderization
Types ¶
type ProcessOptions ¶
type ProcessOptions struct { //MergeKeepFirst When merging output results from rules, if there is a duplicate key, keep the first or the last result found. applies when using flatten output. defaults to true MergeKeepFirst bool //AddRuleInfo Add rule info attributes (name etc) to the output tree when not flatten. defaults to false AddRuleInfo bool //Get all rules's results and merge all outputs into a single flat map. If false, the output will come the same way as the hierarchy of rules. Defaults to true FlattenOutput bool }
ProcessOptions options for rule process
type RequestFilter ¶
RequestFilter Function called on every HTTP call before rules processing. params: request, input attributes returns: error
type ResponseFilter ¶
type ResponseFilter func(w http.ResponseWriter, input map[string]interface{}, output map[string]interface{}, outBytes []byte) (bool, error)
ResponseFilter Function called on every HTTP call after rules processing. params: http response writer, input attribute, output attributes. returns: bool true if ruller should interrupt renderization and rely on what the filter did, error