Skip to main content

Request Routing

A request to one of your APIs crosses several objects before it reaches a service. Knowing which one decides what tells you where to look, and where to change things.

The path of a request, from the caller to the integration

Read this page when an API does not answer as expected, or before designing how several APIs share a gateway. It follows one request from the client to the service and names what decides at each step.

Vocabulary

An access point is a listener of the gateway. An API instance is a route attached to one access point. The console uses the first terms; logs and upstream documentation use the second.

Resource model​

Four objects take part in routing a request. Each decides one thing, and each is managed in its own place.

ObjectDecidesYou manage it in
GatewayWho can reach it at all: the internet, your private network, or the platform onlyAPI Gateways
Access pointThe port, the kind of traffic, and (for HTTPS) the certificateThe gateway
API instanceWhich requests are for this API (by host name and path) and which service answersAPI Instances
PolicyWhether a request may go on, and how the gateway treats itPolicies
Service or upstreamWhere the request finally goesThe integration, or Upstreams

Route matching​

  1. The request arrives on an access point of the gateway.
  2. Among the API instances published on that access point, the gateway keeps those whose host name matches the one of the request.
  3. Among those, it keeps the one whose path matches best: the longest prefix wins.
  4. If none matches, the gateway answers 404.
RequestAPI instances publishedGoes to
orders.example.com/orders/12orders.example.comThat API
api.example.com/orders/12api.example.com + /orders, api.example.com + /The one on /orders
other.example.com/None for that name404

TLS termination and passthrough​

Where TLS ends decides who holds the certificate and what the gateway can see. Only when the gateway terminates TLS can it read the request, and therefore route on the path and apply HTTP policies.

Access pointThe gatewayYour service receives
HTTPSEnds the encryption with its certificate, reads the requestPlain HTTP
TLSDoes not decrypt: it reads only the name asked for, then forwardsThe encrypted connection, which it must decrypt itself
HTTP, TCPForwards as it isWhat the caller sent

Policies that read the request (a key, a token, a header) need the gateway to see it: they apply to HTTP and HTTPS access points, not to TLS or TCP ones.

Policy evaluation order​

A request passes, in this order:

  1. the client traffic policy of the gateway (connections, TLS version);
  2. the security rules, which decide whether the caller is allowed;
  3. the custom logic, if any;
  4. the backend traffic rules (rate limit, timeout, retry, load balancing);
  5. the service.

A policy attached to an API instance takes precedence over the same kind of policy attached to its gateway: the gateway's applies to the APIs that have none of their own.

DNS and wiring automated by the platform​

  • A host name that is not a wildcard is declared in DNS.
  • With a path on a shared address, the prefix is removed before the request reaches your service.
  • Every request is logged, measured and traced, visible in Monitoring.

Troubleshooting by response code​

What the caller receives tells you which stage refused the request. Start from the answer and look at the object named in the last column.

AnswerMeaningLook at
The name does not resolveThe host name is not in DNS yet, or is misspeltThe host name of the API instance
Connection refused, or a timeoutThe gateway is not reachable from where you callThe exposure mode of the gateway
A certificate errorThe certificate does not cover the host name, or has expiredThe certificate of the access point
404No API instance matches the host name and pathThe API instance, and the access point it is on
401, 403A security rule refused the requestThe security policy
429The rate limit was reachedThe backend traffic policy
503No instance of the service is ready, or a cap was reachedThe integration, the circuit breaker
504The service took longer than the timeoutThe integration, the timeout

See also​