Skip to content
Weik.ioDocs
2026.2
Try Weik.io

Upstreams and routes

Weik.io 2026.2

Write where an API sends its calls in YARP's configuration, and give the gateway a credential and connection settings for the upstream. Video

Watch: Publish an API and call it, 3:55

The video publishes an API in front of an integration, deploys it to production and calls it with curl.

On this page

An API version of type: proxy says where the gateway sends each call, in its routes and clusters blocks. These blocks are the configuration of YARP, the .NET reverse proxy that runs inside the gateway, as YARP’s documentation writes it.

Weik.io doesn’t define a subset of YARP, so the features you set in YARP’s configuration work.

Routes and clusters#

finance/apis/invoices.yaml
apiVersion: weik.io/v1
kind: api-version
metadata: { name: v1, project: finance, api: invoices }
spec:
  type: proxy
  routes:                                   # YARP RouteConfig
    - RouteId: pending
      Match: { Path: "/{**rest}" }
      ClusterId: erp
  clusters:                                 # YARP ClusterConfig
    - ClusterId: erp
      LoadBalancingPolicy: RoundRobin
      Destinations:
        erp: { Address: "{{erp-url}}/api/invoices" }

A route matches the part of the path after the API’s prefix and version, so with the prefix /invoices a call to https://api.example.com/invoices/v1/pending matches /{**rest} with rest as pending. A cluster lists the destinations a route sends to. With several destinations, the cluster balances the calls between them.

The destination’s address is a placeholder, so devtest and production send the calls to their own systems.

An integration’s HTTP route is an upstream like any other. Write its address in the cluster, such as http://integrations:8080 for an integration on the same host.

A credential for the upstream#

When the upstream needs a credential, the version’s authentication block gives it to the gateway, which adds it to the calls it forwards. The block’s type is one of these:

Type What the gateway does
header Adds the headers you set, such as an API key the upstream expects
basic Builds the Basic authorization header from a username and a password
oidc Fetches an OAuth client-credentials token from the token endpoint, caches it and sends it
spec:
  authentication:
    type: oidc
    parameters:
      tokenEndpoint: "https://erp.example.com/token"
      clientId: weikio
      clientSecret: "{{erp-client-secret}}"     # a project secret
      scope: invoices.read

The secret stays a placeholder in the version, and each environment resolves it when its route table is built.

The gateway removes the key or token that admitted the caller before it forwards the call.

Connection settings#

YARP’s configuration has no setting for some parts of the connection to the upstream, and connection sets them:

spec:
  connection:
    automaticDecompression: gzip
    connectTimeout: 30s
Setting What it does
allowAutoRedirect Follows the upstream’s redirects
automaticDecompression Decompresses gzip responses
useCookies Keeps a cookie container for the upstream
useProxy Sends the calls through the host’s proxy
connectTimeout Sets how long a connection may take, 15 seconds when it’s not set
clientCertificate Presents a client certificate from a secret on each TLS connection to the upstream and its token endpoint

Store the client certificate as a secret with --as-file, as a PEM file with the certificate, its issuers and its key, or as a PKCS#12 file. For an encrypted key, set clientCertificatePassword.

Weik.io raises a problem 30 days before the client certificate expires. A deploy refuses a certificate that has expired.

Where an API may send#

The gateway’s --upstream-networks limits where the APIs it serves may send calls. A platform administrator sets it on gateways that face the internet.

Retries#

YARP doesn’t retry a call, because it streams the request body and can’t send it twice. To retry calls to an upstream, put an integration in front of it.

Sign in to the live demo

Sign in with the shared viewer account, which can open every screen of the example projects and can't change anything.

E-mail
viewer@demo.weik.io
Password
try-weikio-live-demo
Open the live demo