Router Expressions Language Reference for Kong Gateway
With the release of version 3.0, Kong Gateway now ships with a new router. The new router can describe routes using a domain-specific language called Expressions. Expressions can describe routes or paths as combinations of logical operations called “predicates”. This document serves as a reference for all of the available operators and fields. If you want to learn how to configure routes using Expressions read How to configure routes using Expressions.
Kong router Expressions are designed as combinations of simple comparisons called “predicates”. All predicates have one of the following form:
field op value transformation(field) op value
http.path ^= "/prefix/" lower(http.path) ^= "/prefix/"
Note: transformations only works on fields, it will not work on the value side of the predicate. This means you can not write:
http.path ^= lower("/preFIX/")
Predicates can be grouped with parenthesis
() or logical operators
(http.path ^= "/prefix/" && net.port == 80) || http.method == "POST"
Router expressions are strongly typed. The operators available to each field depends on the type of that field. For example, you can not perform string comparisons on a integer type field.
||The protocol used to communicate with the upstream application.||String|
||Server end port number.||Int|
||Server name indication.||String|
||HTTP methods that match a route.||String|
||Lists of domains that match a route.||String|
||Normalized request path (without query parameters).||String|
||Value of header
|not in||Does not contain|
|lower()||turn the uppercase letters into lowercase|
|>=||Greater than or equal|
|<=||Less than or equal|