Client Route Features
Apinizer’s Client Route feature enables more flexible and dynamic routing of incoming requests in the API Gateway:Multiple Paths
Host-Based Routing
Header-Based Routing
Method-Based Routing
How Does Client Route Work?
The Client Route feature evaluates incoming requests according to a specific priority order and routes them to the correct API Proxy.Workflow
The following diagram shows how request and response flow occurs through the Gateway:Routing Priority Order
The Gateway evaluates incoming requests according to the following priority order:1. Relative Path
2. Hosts
3. Headers
4. Methods
Matching Logic
Hosts (OR Logic)
Hosts (OR Logic)
hostname_x.com or hostname_y.com, the condition is met.Headers (AND Logic)
Headers (AND Logic)
testmode: true and test: true headers must be present in the request.Path Matching
Path Matching
- Relative path matching has the highest priority
- More specific (longer) paths are evaluated before more general (shorter) paths
- If exact match is not found, the closest parent path is used
Method Matching
Method Matching
- Method check has the lowest priority
- If not specified, all HTTP methods are accepted
Wildcard Hostname Usage
Apinizer supports wildcard (joker character) usage in host definitions to provide flexibility. Wildcard hostnames allow all Host header values matching a specific pattern to meet the condition and thus match with the relevant Route.Wildcard Rules
Wildcard Examples
Left Side Wildcard
- a.example.com
- x.y.example.com
- api.example.com
- test.subdomain.example.com
Right Side Wildcard
- example.com
- example.org
- example.net
- example.io
Example Scenario
The following table shows 5 different API Proxies and their configured Client Route configurations:| Proxy ID | Relative Path | Methods | Hosts (OR) | Headers (AND) |
|---|---|---|---|---|
| 1 | /jokes | - | - | testmode:true, test:true |
| 2 | /jokes | - | hostname_x.com, hostname_y.com | - |
| 3 | /jokes1/endpoint_x | - | - | - |
| 4 | /jokes1 | - | - | - |
| 5 | /jokes | - | - | - |
Routing Examples
According to this configuration, incoming requests are routed as follows:Example 1: Basic Routing
Example 1: Basic Routing
Example 2: Host-Based Routing
Example 2: Host-Based Routing
Example 3: Routing with Missing Header
Example 3: Routing with Missing Header
Example 4: Complete Header Match
Example 4: Complete Header Match
Example 5: Path Priority - Basic Path
Example 5: Path Priority - Basic Path
Example 6: Path Priority - Long Path
Example 6: Path Priority - Long Path
Example 7: Path with Sub-path
Example 7: Path with Sub-path
Example 8: Path Match - Different Sub-path
Example 8: Path Match - Different Sub-path
/jokes1 matched)Example 9: Host and Header Combination
Example 9: Host and Header Combination
Example 10: Different Path with Host and Header
Example 10: Different Path with Host and Header
Important Notes
Path Matching
Path Matching
- Relative path matching has the highest priority
- More specific (longer) paths are evaluated before more general (shorter) paths
- If exact match is not found, the closest parent path is used
Host Matching
Host Matching
- Multiple hosts can be defined
- Hosts work with OR logic
- If the host value in the request matches any of the defined hosts, the condition is met
Header Matching
Header Matching
- Multiple headers can be defined
- Headers work with AND logic
- All defined headers must be present in the request
- In case of missing or incorrect headers, proceed to the next appropriate proxy
Method Matching
Method Matching
- Method check has the lowest priority
- If not specified, all HTTP methods are accepted
Routing Combination Table
This table shows how the API Proxy is selected from the API Proxy’s perspective:| Status | Description |
|---|---|
| None | Not present in the API proxy definition. What the client sends is not checked. |
| Matched | Present in the API proxy definition. What the client sends is checked, and it sent the expected value. |
| Not Matched | Present in the API proxy definition. What the client sends is checked, but it did not send the expected value. |

