Routes
Routes define how incoming requests are matched and routed to backend services.
Route Structure
Section titled “Route Structure”interface Route { id: string; name: string; serviceId?: string; protocols?: string[]; // ["http", "https"] methods?: string[]; // ["GET", "POST", ...] hosts?: string[]; // ["api.example.com"] paths?: string[]; // ["/api/v1/*"] headers?: Record<string, string | string[]>; stripPath?: boolean; preserveHost?: boolean; tags?: string[];}Path Matching Patterns
Section titled “Path Matching Patterns”Creating Routes
Section titled “Creating Routes”Path Handling Options
Section titled “Path Handling Options”Strip Path
Section titled “Strip Path”Remove matched prefix before forwarding:
{ "paths": ["/api/v1/*"], "stripPath": true}Request: /api/v1/users → Backend receives: /users
Preserve Host
Section titled “Preserve Host”Keep original host header when forwarding:
{ "preserveHost": true}Default: gateway replaces host with backend target host.
Route Priority
Section titled “Route Priority”Routes are matched by specificity:
- Exact paths before wildcards
- More specific wildcards before broader ones
- Regex priority can override order
{ "regexPriority": 100 // Higher priority wins}Managing Routes
Section titled “Managing Routes”List Routes
Section titled “List Routes”curl http://localhost:8080/api/routesGet Routes by Service
Section titled “Get Routes by Service”curl http://localhost:8080/api/routes?serviceId=service_abc123Update Route
Section titled “Update Route”curl -X PATCH http://localhost:8080/api/routes/route_xyz789 \ -H "Content-Type: application/json" \ -d '{ "methods": ["GET", "POST", "PUT", "DELETE"] }'Delete Route
Section titled “Delete Route”curl -X DELETE http://localhost:8080/api/routes/route_xyz789Route-Level Plugins
Section titled “Route-Level Plugins”Bind plugins to specific routes:
curl -X POST http://localhost:8080/api/plugins \ -H "Content-Type: application/json" \ -d '{ "routeId": "route_xyz789", "pluginName": "key-auth", "config": { "required": true } }'Host-Based Routing
Section titled “Host-Based Routing”Route based on domain:
{ "hosts": ["api.example.com", "internal.example.com"]}Different domains can route to different services.
Protocol Restrictions
Section titled “Protocol Restrictions”Limit to specific protocols:
{ "protocols": ["https"] // Only HTTPS requests}Next Steps
Section titled “Next Steps”- Services - Services contain routes
- Upstreams - Backend server pools
- Proxy Engine - Request processing