Ana içeriğe atla

API Proxy Client Route Usage Guide

Client Route Overview

Client Route Overview

Overview

Apinizer’s Client Route feature enables more flexible and dynamic routing of incoming requests in the API Gateway. With this feature:
  • Multiple relative paths can be defined for a proxy
  • Routing can be done to different proxies based on host information
  • Routing rules can be created based on HTTP header values
  • Method-based routing can be performed
Before this feature was developed, only a single unique relative path could be defined for each proxy. With the new feature, multiple proxies with the same relative path can be created, and dynamic routing can be performed between them based on host, header, or method information.

How Does Client Route Work?

The Client Route feature evaluates incoming requests according to a specific priority order and routes them to the correct proxy.

Routing Priority Order

The Gateway evaluates incoming requests according to the following priority order:
  1. Relative Path (Highest priority)
  2. Hosts
  3. Headers
  4. Methods (Lowest priority)

Matching Logic

  • Hosts: When multiple hosts are defined, it works with OR logic. That is, matching any one of the defined hosts is sufficient.
  • Headers: When multiple headers are defined, it works with AND logic. That is, all defined headers must match.

Wildcard Hostname Usage

Apinizer supports wildcard (joker character) usage to provide flexibility in host definitions. Wildcard hostnames allow all Host header values that match a certain pattern to satisfy the condition and thus match the related Route.

Wildcard Rules

Wildcard hostnames must comply with the following rules:
  • Can contain only one asterisk (*) in the leftmost or rightmost label of the domain
  • Asterisk can be used at the beginning or end of the domain

Wildcard Examples

Left-Side Wildcard

*.example.com
This definition enables matching of the following Host values:
  • a.example.com
  • x.y.example.com
  • api.example.com
  • test.subdomain.example.com

Right-Side Wildcard

example.*
This definition enables matching of the following Host values:
  • example.com
  • example.org
  • example.net
  • example.io

## Example Scenario

The table below shows 5 different proxies and the Client Route configurations defined for them.

| 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

**Request:**

```text
GET https://<ACCESS_URL>/jokes
Result: Routed to Proxy 5 (default proxy since no condition is met)

Example 2: Host-Based Routing

Request:
GET https://<ACCESS_URL>/jokes
Host: hostname_x.com
Result: Routed to Proxy 2 (host condition met)

Example 3: Routing with Missing Header

Request:
GET https://<ACCESS_URL>/jokes
testmode: true
Result: Routed to Proxy 5 (Proxy 1 requires both headers, only one is provided)

Example 4: Full Header Match

Request:
GET https://<ACCESS_URL>/jokes
testmode: true
test: true
Result: Routed to Proxy 1 (all header conditions met)

Example 5: Path Priority - Basic Path

Request:
GET https://<ACCESS_URL>/jokes1
Result: Routed to Proxy 4 (exact path match)

Example 6: Path Priority - Long Path

Request:
GET https://<ACCESS_URL>/jokes1/endpoint_x
Result: Routed to Proxy 3 (more specific path takes priority)

Example 7: Path with Sub-Path

Request:
GET https://<ACCESS_URL>/jokes1/endpoint_x/endpoint_y
Result: Routed to Proxy 3 (closest parent path match)

Example 8: Path Match - Different Sub-Path

Request:
GET https://<ACCESS_URL>/jokes1/endpoint_y
Result: Routed to Proxy 4 (matched /jokes1 as parent path)

Example 9: Host and Header Combination

Request:
GET https://<ACCESS_URL>/jokes
Host: hostname_x.com
testmode: true
test: true
Result: Routed to Proxy 2 (host has higher priority than header)

Important Notes

Path Matching

  • Relative path matching has the highest priority.
  • More specific (longer) paths are evaluated before more general (shorter) paths.
  • If an exact match is not found, the closest parent path is used.

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

  • Multiple headers can be defined.
  • Headers work with AND logic.
  • All headers defined in the request must be present.
  • In case of missing or incorrect headers, it moves to the next suitable proxy.

Method Matching

  • Method checking has the lowest priority.
  • If not specified, all HTTP methods are accepted.
The Client Route feature allows you to easily manage complex routing scenarios in your API Gateway. By understanding the priority order and matching logic correctly, you can create flexible and powerful API routing configurations.

Routing Combination Table

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. This table shows from the API Proxy perspective how the API Proxy is selected.
#HOSTPATHMETHODHEADERRESULTEXPLANATION
1NoneNoneNoneNone✓ SELECTEDNo criteria defined
2NoneNoneNoneMatched✓ SELECTEDAll defined criteria OK (HEADER)
3NoneNoneNoneNot Matched✗ REJECTEDCannot route because HEADER did not match
4NoneNoneMatchedNone✓ SELECTEDAll defined criteria OK (METHOD)
5NoneNoneMatchedMatched✓ SELECTEDAll defined criteria OK (METHOD, HEADER)
6NoneNoneMatchedNot Matched✗ REJECTEDCannot route because HEADER did not match
7NoneNoneNot MatchedNone✗ REJECTEDCannot route because METHOD did not match
8NoneNoneNot MatchedMatched✗ REJECTEDCannot route because METHOD did not match
9NoneNoneNot MatchedNot Matched✗ REJECTEDCannot route because METHOD, HEADER did not match
10NoneMatchedNoneNone✓ SELECTEDAll defined criteria OK (PATH)
11NoneMatchedNoneMatched✓ SELECTEDAll defined criteria OK (PATH, HEADER)
12NoneMatchedNoneNot Matched✗ REJECTEDCannot route because HEADER did not match
13NoneMatchedMatchedNone✓ SELECTEDAll defined criteria OK (PATH, METHOD)
14NoneMatchedMatchedMatched✓ SELECTEDAll defined criteria OK (PATH, METHOD, HEADER)
15NoneMatchedMatchedNot Matched✗ REJECTEDCannot route because HEADER did not match
16NoneMatchedNot MatchedNone✗ REJECTEDCannot route because METHOD did not match
17NoneMatchedNot MatchedMatched✗ REJECTEDCannot route because METHOD did not match
18NoneMatchedNot MatchedNot Matched✗ REJECTEDCannot route because METHOD, HEADER did not match
19NoneNot MatchedNoneNone✗ REJECTEDCannot route because PATH did not match
20NoneNot MatchedNoneMatched✗ REJECTEDCannot route because PATH did not match
21NoneNot MatchedNoneNot Matched✗ REJECTEDCannot route because PATH, HEADER did not match
22NoneNot MatchedMatchedNone✗ REJECTEDCannot route because PATH did not match
23NoneNot MatchedMatchedMatched✗ REJECTEDCannot route because PATH did not match
24NoneNot MatchedMatchedNot Matched✗ REJECTEDCannot route because PATH, HEADER did not match
25NoneNot MatchedNot MatchedNone✗ REJECTEDCannot route because PATH, METHOD did not match
26NoneNot MatchedNot MatchedMatched✗ REJECTEDCannot route because PATH, METHOD did not match
27NoneNot MatchedNot MatchedNot Matched✗ REJECTEDCannot route because PATH, METHOD, HEADER did not match
28MatchedNoneNoneNone✓ SELECTEDAll defined criteria OK (HOST)
29MatchedNoneNoneMatched✓ SELECTEDAll defined criteria OK (HOST, HEADER)
30MatchedNoneNoneNot Matched✗ REJECTEDCannot route because HEADER did not match
31MatchedNoneMatchedNone✓ SELECTEDAll defined criteria OK (HOST, METHOD)
32MatchedNoneMatchedMatched✓ SELECTEDAll defined criteria OK (HOST, METHOD, HEADER)
33MatchedNoneMatchedNot Matched✗ REJECTEDCannot route because HEADER did not match
34MatchedNoneNot MatchedNone✗ REJECTEDCannot route because METHOD did not match
35MatchedNoneNot MatchedMatched✗ REJECTEDCannot route because METHOD did not match
36MatchedNoneNot MatchedNot Matched✗ REJECTEDCannot route because METHOD, HEADER did not match
37MatchedMatchedNoneNone✓ SELECTEDAll defined criteria OK (HOST, PATH)
38MatchedMatchedNoneMatched✓ SELECTEDAll defined criteria OK (HOST, PATH, HEADER)
39MatchedMatchedNoneNot Matched✗ REJECTEDCannot route because HEADER did not match
40MatchedMatchedMatchedNone✓ SELECTEDAll defined criteria OK (HOST, PATH, METHOD)
41MatchedMatchedMatchedMatched✓ SELECTEDAll defined criteria OK (HOST, PATH, METHOD, HEADER)
42MatchedMatchedMatchedNot Matched✗ REJECTEDCannot route because HEADER did not match
43MatchedMatchedNot MatchedNone✗ REJECTEDCannot route because METHOD did not match
44MatchedMatchedNot MatchedMatched✗ REJECTEDCannot route because METHOD did not match
45MatchedMatchedNot MatchedNot Matched✗ REJECTEDCannot route because METHOD, HEADER did not match
46MatchedNot MatchedNoneNone✗ REJECTEDCannot route because PATH did not match
47MatchedNot MatchedNoneMatched✗ REJECTEDCannot route because PATH did not match
48MatchedNot MatchedNoneNot Matched✗ REJECTEDCannot route because PATH, HEADER did not match
49MatchedNot MatchedMatchedNone✗ REJECTEDCannot route because PATH did not match
50MatchedNot MatchedMatchedMatched✗ REJECTEDCannot route because PATH did not match
51MatchedNot MatchedMatchedNot Matched✗ REJECTEDCannot route because PATH, HEADER did not match
52MatchedNot MatchedNot MatchedNone✗ REJECTEDCannot route because PATH, METHOD did not match
53MatchedNot MatchedNot MatchedMatched✗ REJECTEDCannot route because PATH, METHOD did not match
54MatchedNot MatchedNot MatchedNot Matched✗ REJECTEDCannot route because PATH, METHOD, HEADER did not match
55Not MatchedNoneNoneNone✗ REJECTEDCannot route because HOST did not match
56Not MatchedNoneNoneMatched✗ REJECTEDCannot route because HOST did not match
57Not MatchedNoneNoneNot Matched✗ REJECTEDCannot route because HOST, HEADER did not match
58Not MatchedNoneMatchedNone✗ REJECTEDCannot route because HOST did not match
59Not MatchedNoneMatchedMatched✗ REJECTEDCannot route because HOST did not match
60Not MatchedNoneMatchedNot Matched✗ REJECTEDCannot route because HOST, HEADER did not match
61Not MatchedNoneNot MatchedNone✗ REJECTEDCannot route because HOST, METHOD did not match
62Not MatchedNoneNot MatchedMatched✗ REJECTEDCannot route because HOST, METHOD did not match
63Not MatchedNoneNot MatchedNot Matched✗ REJECTEDCannot route because HOST, METHOD, HEADER did not match
64Not MatchedMatchedNoneNone✗ REJECTEDCannot route because HOST did not match
65Not MatchedMatchedNoneMatched✗ REJECTEDCannot route because HOST did not match
66Not MatchedMatchedNoneNot Matched✗ REJECTEDCannot route because HOST, HEADER did not match
67Not MatchedMatchedMatchedNone✗ REJECTEDCannot route because HOST did not match
68Not MatchedMatchedMatchedMatched✗ REJECTEDCannot route because HOST did not match
69Not MatchedMatchedMatchedNot Matched✗ REJECTEDCannot route because HOST, HEADER did not match
70Not MatchedMatchedNot MatchedNone✗ REJECTEDCannot route because HOST, METHOD did not match
71Not MatchedMatchedNot MatchedMatched✗ REJECTEDCannot route because HOST, METHOD did not match
72Not MatchedMatchedNot MatchedNot Matched✗ REJECTEDCannot route because HOST, METHOD, HEADER did not match
73Not MatchedNot MatchedNoneNone✗ REJECTEDCannot route because HOST, PATH did not match
74Not MatchedNot MatchedNoneMatched✗ REJECTEDCannot route because HOST, PATH did not match
75Not MatchedNot MatchedNoneNot Matched✗ REJECTEDCannot route because HOST, PATH, HEADER did not match
76Not MatchedNot MatchedMatchedNone✗ REJECTEDCannot route because HOST, PATH did not match
77Not MatchedNot MatchedMatchedMatched✗ REJECTEDCannot route because HOST, PATH did not match
78Not MatchedNot MatchedMatchedNot Matched✗ REJECTEDCannot route because HOST, PATH, HEADER did not match
79Not MatchedNot MatchedNot MatchedNone✗ REJECTEDCannot route because HOST, PATH, METHOD did not match
80Not MatchedNot MatchedNot MatchedMatched✗ REJECTEDCannot route because HOST, PATH, METHOD did not match
81Not MatchedNot MatchedNot MatchedNot Matched✗ REJECTEDCannot route because HOST, PATH, METHOD, HEADER did not match