- A condition primitive is a basic and built-in function which check some specified condition matched or not.
// return true if the request Host is "www.bfe-networks.com" or "bfe-networks.com"
req_host_in("www.bfe-networks.com|bfe-networks.com")
- BFE provides a set of built-in condition primitives
- A condition expression is a series of condition primitives combined with operators (e.g. AND, OR, NOT, etc).
// return ture if the request host is "bfe-networks.com" and the request method is "GET"
req_host_in("bfe-networks.com") && req_method_in("GET")
- The supported operators are described in another section below.
- You can define a variable and assign a condition expression to it.
// define a condition variable
bfe_host = req_host_in("bfe-networks.com")
-
An advanced condition expression is a series of condition primitives and condition variables combined with operators (e.g. AND, OR, NOT, etc).
-
In an advanced condition expression, the condition variable is identified by "$" prefix
// return true if the value of new_host is true and the request method is GET
$new_host && req_method_in("GET")
A condition primitive is shown as follows:
func_name(params)
- func_name is the name of condition primitive
- params are the parameters condition primitive
- The type of return value is bool
Condition Expression(CE) grammar is defined as follows:
CE = CE && CE
| CE || CE
| ( CE )
| ! CE
| ConditionPrimitive
Advanced Condition Expression(ACE) grammar is defined as follows:
ACE = ACE && ACE
| ACE || ACE
| ( ACE)
| ! ACE
| ConditionPrimitive
| ConditionVariable
The precedence and associativity of operators are similar to the C language. The following table lists the precedence and associativity of all operators. Operators are listed top to bottom, in descending precedence.
Precedence | Operator | Description | Associativity |
---|---|---|---|
1 | () | parentheses (grouping) | Left-to-right |
2 | ! | logical NOT | Right-to-left |
3 | && | logical AND | Left-to-right |
4 | || | logical OR | Left-to-right |