Skip to content
Kong Logo | Kong Docs Logo
search
  • We're Hiring!
  • Docs
    • Kong Gateway
    • Kong Konnect
    • Kong Mesh
    • Plugin Hub
    • decK
    • Kubernetes Ingress Controller
    • Insomnia
    • Kuma

    • Docs contribution guidelines
  • Plugin Hub
  • Support
  • Community
  • Kong Academy
Get a Demo Start Free Trial
  • Kong Gateway
  • Kong Konnect
  • Kong Mesh
  • Plugin Hub
  • decK
  • Kubernetes Ingress Controller
  • Insomnia
  • Kuma

  • Docs contribution guidelines
  • 3.3.x (latest)
  • 3.2.x
  • 3.1.x
  • 3.0.x
  • 2.8.x
  • 2.7.x
  • 2.6.x
  • Older Enterprise versions (2.1-2.5)
  • Older OSS versions (2.1-2.5)
  • Archive (pre-2.1)

github-edit-pageEdit this page

report-issueReport an issue

enterprise-switcher-iconSwitch to OSS

On this pageOn this page
  • General design
  • Types
  • Available fields
  • String
  • String transformations
  • Integer
  • IP
  • Boolean
  • More information
Kong Gateway
3.2.x
  • Home
  • Kong Gateway
  • Reference
  • Router Expressions Language Reference for Kong Gateway
You are browsing documentation for an outdated version. See the latest documentation here.

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.

General design

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

Example:

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 ||, &&:

Example:

(http.path ^= "/prefix/" && net.port == 80) || http.method == "POST"

Types

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.

Available fields

Field Description Type
net.protocol The protocol used to communicate with the downstream application. String
net.port Server end port number. Int
tls.sni Server name indication. String
http.method HTTP methods that match a route. String
http.host Lists of domains that match a route. String
http.path Normalized request path (without query parameters). String
http.headers.header_name Value of header Header-Name. Header names are converted to lower case, and - are replaced to _. String

String

Operator Meaning
== Equals
!= Not equals
~ Regex matching
^= Prefix matching
=^ Suffix matching
in Contains
not in Does not contain

String transformations

Transformation Meaning
lower() turn the uppercase letters into lowercase

Integer

Operator Meaning
== Equals
!= Not equals
> Greater than
>= Greater than or equal
< Less than
<= Less than or equal

IP

Operator Meaning
== Equals
!= Not equals
in Contains

Boolean

Operator Meaning
&& Logical And
|| Logical Or

More information

  • Expressions repository
  • How to configure routes using Expressions
Thank you for your feedback.
Was this page useful?
  • Kong
    THE CLOUD CONNECTIVITY COMPANY

    Kong powers reliable digital connections across APIs, hybrid and multi-cloud environments.

    • Company
    • Customers
    • Events
    • Investors
    • Careers Hiring!
    • Partners
    • Press
    • Contact
  • Products
    • Kong Konnect
    • Kong Gateway
    • Kong Mesh
    • Get Started
    • Pricing
  • Resources
    • eBooks
    • Webinars
    • Briefs
    • Blog
    • API Gateway
    • Microservices
  • Open Source
    • Install Kong Gateway
    • Kong Community
    • Kubernetes Ingress
    • Kuma
    • Insomnia
  • Solutions
    • Decentralize
    • Secure & Govern
    • Create a Dev Platform
    • API Gateway
    • Kubernetes
    • Service Mesh
Star
  • Terms•Privacy
© Kong Inc. 2023