Instead of retyping the same expression multiple times in multiple policies, you can configure a named expression and refer to the name any time you want to use the expression in a policy. For example, you could create the following named expressions:
You can then use these named expressions in a policy expression. For example, the following is a legal expression based on the preceding examples:
ThisExpression || ThatExpression
You can use the name of a default syntax expression as the prefix to
a function. The named expression can be either a simple expression
or a compound expression. The function must be one that can operate
on the type of data that is returned by the named expression.
Example 1: Simple Named Expression as a Prefix
The following simple named expression, which identifies a text
string, can be used as a prefix to the
which works with text data:
If the name of the expression is top1KB, you can use top1KB.AFTER_STR("username") instead of
Example 2: Compound Named Expression as a Prefix
You can create a compound named expression called
basic_header_value to concatenate the user name in a request, a
colon (:), and the user's password, as follows:
add policy expression basic_header_value
"HTTP.REQ.USER.NAME + \":\" + HTTP.REQ.USER.PASSWD"
You can then use the name of the expression in a rewrite action,
as shown in the following example:
add rewrite action
insert_b64encoded_authorization insert_http_header authorization
'"Basic " + basic_header_value.b64encode' -bypassSafetyCheck
In the example, in the expression that is used to construct the
value of the custom header, the B64 encoding algorithm is applied
to the string returned by the compound named expression.
You can also use a named expression (either by
itself or as a prefix to a function) to create the text expression
for the replacement target in a rewrite.