This page describes how to use the Mixer configuration expression language (CEXL).
CEXL accepts a subset of Go expressions, which defines the syntax. CEXL implements a subset of the Go operators that constrains the set of accepted Go expressions. CEXL also supports arbitrary parenthesization.
CEXL supports the following functions.
||||First non empty|
|Glob match||Matches prefix or suffix based on the location of |
|Convert a textual e-mail into the ||Use the |
|Convert a textual DNS name into the ||Use the |
|Convert a textual IPv4 address into the ||Use the |
|Convert a textual timestamp in RFC 3339 format into the ||Use the |
|Convert a textual URI into the ||Use the |
|Regular expression match||Matches |
|string prefix match||Checks whether |
|string postfix match||Checks whether |
|Create an empty string map|
|Simulate ternary operator||Returns |
CEXL variables are attributes from the typed attribute vocabulary, constants are implicitly typed and, functions are explicitly typed.
Mixer validates a CEXL expression and resolves it to a type during configuration validation. Selectors must resolve to a boolean value and mapping expressions must resolve to the type they are mapping into. Configuration validation fails if a selector fails to resolve to a boolean or if a mapping expression resolves to an incorrect type.
For example, if an operator specifies a string label as
request.size | 200, validation fails because the expression resolves to an integer.
If an expression uses an attribute that is not available during request processing, the expression evaluation fails. Use the
| operator to provide a default value if an attribute may be missing.
For example, the expression
request.auth.principal == "user1" fails evaluation if the
request.auth.principal attribute is missing. The
| (OR) operator addresses the problem:
(request.auth.principal | "nobody" ) == "user1".
|True if the user is admin or in the admin group.|
|boolean||True if |
|True if app label is reviews and version label is v3, false otherwise.|