Documentation ¶
Overview ¶
Package matcher provides a simple "rule" language that may be used inside NextDHCP plugin directives. The matcher library is based on github.com/Knetic/govaluate
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseConditions ¶
func ParseConditions(c *caddy.Controller) (string, error)
ParseConditions parses the current dispenser block for if and if_op conditions and returns them as a single, concatenated expression string usable for govaluate.NewEvaluableExpression() and similar
Types ¶
type ExprFunc ¶
type ExprFunc func(args ...interface{}) (interface{}, error)
ExprFunc can be used expose functions to matcher expressions
type Matcher ¶
type Matcher struct {
// contains filtered or unexported fields
}
Matcher is a DHCP message matcher
func SetupMatcher ¶
SetupMatcher parses the current dispenser block and returns a DHCP message matcher
func SetupMatcherRemainingArgs ¶
SetupMatcherRemainingArgs creates a new DHCPv4 coniditon matcher from the remaining args available in the current dispenser line
func SetupMatcherString ¶
SetupMatcherString creates a new DHCPv4 condition matcher form the provided string
func (*Matcher) EmptyCondition ¶
EmptyCondition returns true if there's no condition for the matcher. In this case, any call to Match or MatchParams will return true
func (*Matcher) Match ¶
Match evaluates the expression stored in the matcher against the given request and response message
func (*Matcher) MatchParams ¶
func (m *Matcher) MatchParams(params govaluate.Parameters) (bool, error)
MatchParams executes the parsed govaluate expression and returns the resulting boolean output. If the return value of the expression is not a boolean an error is returned