Kong: longer paths win, and regex_priority breaks ties

Routes are matched most-specific-first by path length, not by creation order. Two regex routes of equal specificity are ordered by regex_priority, highest first.

Code
# /billing/invoices wins over /billing for GET /billing/invoices/42
curl -X POST http://localhost:8001/services/a/routes --data 'paths[]=/billing'
curl -X POST http://localhost:8001/services/b/routes --data 'paths[]=/billing/invoices'

# explicit ordering between regex routes
curl -X POST http://localhost:8001/services/c/routes \
  --data 'paths[]=~/billing/(\d+)' --data regex_priority=100
Output
GET /billing/invoices/42  ->  service b
GET /billing/anything     ->  service a

# The evaluation order is: plain paths by descending length, then regex
# paths by descending regex_priority.
#
# A catch-all route with paths[]=/ will never shadow a more specific one -
# which makes it safe as a default backend.
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