Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Routes

Routes map incoming request paths to backend clusters. Meridian uses prefix-based matching — the first route whose prefix matches the request path wins.

[[routes]]
prefix = "/api"
cluster = "api-backend"
timeout_ms = 15000

[[routes]]
prefix = "/static"
cluster = "cdn-backend"

[[routes]]
prefix = "/"
cluster = "default-backend"

Fields

FieldTypeRequiredDescription
prefixstringyesPath prefix to match
clusterstringyesTarget cluster name
timeout_msintegernoRequest-level timeout in milliseconds
retry_policytablenoRetry configuration

Matching Order

Routes are evaluated in the order they appear in the configuration file. Put more specific prefixes first:

# Correct: specific routes first
[[routes]]
prefix = "/api/v2"
cluster = "api-v2"

[[routes]]
prefix = "/api"
cluster = "api-v1"

[[routes]]
prefix = "/"
cluster = "default"

Path Normalization

Before matching, request paths are normalized:

  • Double slashes collapsed: //api//data becomes /api/data
  • Dot segments resolved: /api/../secret becomes /secret
  • Dot segments removed: /api/./data becomes /api/data
  • Traversal beyond root clamped: /../../etc/passwd becomes /etc/passwd

This prevents routing bypass attacks where an attacker uses path manipulation to reach unintended backends.

Retry Policy

[[routes]]
prefix = "/api"
cluster = "api-backend"

[routes.retry_policy]
num_retries = 3
retry_on = ["503", "connect-failure"]