Skip to main content

Version: 3.2.16.7

API7 Expressions

API7 Expressions are combinations of variables, operators, and values that can be evaluated to a result, such as a Boolean value, true or false. Expressions can be used in configurations for route matching, request filtering, selective plugin applications, log enrichment, and more.

API7 Enterprise supports the evaluation of comparison operators and logical operators, as well as regular expressions (RegEx).

Comparison Operators

API7 Enterprise supports the following comparison operators to be used with built-in variables in expressions:

OperatorDescriptionExample
==equal["arg_version", "==", "v2"]
~=not equal["arg_version", "~=", "v2"]
>greater than["arg_ttl", ">", 3600]
>=greater than or equal to["arg_ttl", ">=", 3600]
<less than["arg_ttl", "<", 3600]
<=less than or equal to["arg_ttl", "<=", 3600]
~~match RegEx["arg_env", "~~", "[Dd]ev"]
~*match RegEx (case-insensitive)["arg_env", "~~", "dev"]
inexist in the right-hand side["arg_version", "in", ["v1","v2"]]
hascontain item in the right-hand side["graphql_root_fields", "has", "owner"]
!reverse the adjacent operator["arg_env", "!", "~~", "[Dd]ev"]
ipmatchmatch IP address["remote_addr", "ipmatch", ["192.168.102.40", "192.168.3.0/24"]]

Logical Operators

APISIX supports the following logical operators:

OperatorExplanation
ANDAND(A,B) is true if both A and B are true.
OROR(A,B) is true if either A or B is true.
!AND!AND(A,B) is true if either A or B is false.
!OR!OR(A,B) is true only if both A and B are false.

You can use logical operators to combine multiple expressions for evaluation, such as the following:

[
"AND",
["arg_version", "==", "v2"],
[
"OR",
["arg_action", "==", "signup"],
["arg_action", "==", "subscribe"]
]
]

API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2024. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation