Kong: a Route can match on path, host, method, header or SNI

All the criteria on one Route are ANDed; the values within one criterion are ORed. That is how a single Route matches two hostnames but only one method.

Code
curl -X POST http://localhost:8001/services/billing/routes \
  --data name=r1 \
  --data 'paths[]=/billing' \
  --data 'hosts[]=api.example.com' --data 'hosts[]=api2.example.com' \
  --data 'methods[]=GET' --data 'methods[]=POST' \
  --data 'headers.X-Api-Version[]=2'

# regex paths, marked with ~
  --data 'paths[]=~/billing/v\d+/invoices'
Output
matches:     GET  api.example.com/billing      X-Api-Version: 2
does NOT:    GET  api.example.com/billing      (no version header)
does NOT:    DELETE api.example.com/billing

# Kong 3.x also has an expression router, which is clearer for complex rules:
#   --data expression='http.path ^= "/billing" && http.method == "GET"'
#   --data router_flavor=expressions   (in kong.conf)
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-25