Skip to content
Weik.ioDocs
2026.2
Try Weik.io

The gateway on a laptop

Weik.io 2026.2

Run the gateway alone on plain HTTP on a laptop to try an API and the gateway's rules.

On this page

On a laptop the gateway runs alone on plain HTTP. It’s the same program as a hub gateway and a site gateway. Use it to try an API and the gateway’s rules on your own machine.

Start it#

When you open the Try Weik.io dev container, the gateway starts and connects to the hub’s message server there.

The gateway accepts calls on http://localhost:8581, which is its entrance public. Run the commands on this page in the dev container’s terminal, where that address answers.

When the gateway starts while the message server is down, it serves a copy of the API routes it last received.

Call an API without setup#

weikio-backend init --dev creates a gateway called devtest in the environment devtest:

  • It’s the environment’s default gateway.
  • It answers on the entrance public.
  • It’s open to every caller.
  • Its hostname is localhost.

Because it’s the default, you deploy and subscribe without naming a gateway, then call it on the local port:

Terminal
$ weikio apply -f ./hello-api.yaml
$ weikio api deploy sandbox/hello@v1 --env devtest
$ weikio subscription create sandbox/me --env devtest --api hello --type apikey
$ curl -H "X-Api-Key: <the key it printed>" http://localhost:8581/hello/v1/world

The hostname localhost answers on any local port and gets no certificate. When the installation’s address is localhost, which no gateway may use, init creates the gateway with no hostname and prints the command that adds the name you call it by.

To start an API of your own, run weikio init hello --kind api --project sandbox. It writes hello/hello.yaml with the API and a proxy version.

The edit loop#

A deployment serves the definition the version had when you deployed it. After you edit a version with weikio apply or in the admin UI’s editor, weikio apply prints a line for each environment that serves an older definition:

You see
sandbox/hello@v1 in devtest serves an older definition. Deploy it with: weikio api deploy sandbox/hello@v1 --env devtest

To serve the edit, run that line or press Deploy on the API’s page. Values and secrets aren’t part of the definition, so a changed value reaches the gateway without a new deploy.

In a repository, write the devtest api-deployment without a definition and apply it with the version. Each apply then deploys the current definition.

Try the rules#

The rules a hub gateway enforces work on the laptop too.

Who may connect#

The gateway admits a caller by the address the connection comes from. Linux answers on all of 127.0.0.0/8, so a gateway created with --networks 127.0.0.1/32 rejects curl --interface 127.0.0.2 ... and serves curl from 127.0.0.1. A rejected caller gets the same reply as a call to a name that doesn’t exist.

TLS and client certificates#

To have the gateway terminate TLS itself, start it with an HTTPS address, such as --urls https://localhost:8443. Then create a second gateway that requires client certificates, and upload a test certificate for its name:

Terminal
$ weikio gateway create partner-local --env devtest --hostname partner.localhost --networks 127.0.0.0/8 \
    --client-certificate required --authority test=test-ca.pem --server-certificate local=partner.localhost.pem,partner.localhost.key
$ weikio subscription create sandbox/partner --env devtest --gateway partner-local --api hello --type certificate \
    --certificate-authority test --certificate-name partner.example
$ curl --cacert test-ca.pem --cert partner.pem --key partner.key --resolve partner.localhost:8443:127.0.0.1 \
    https://partner.localhost:8443/hello/v1/world

Only devtest is the default gateway, so deploy the API onto partner-local by name with weikio api deploy sandbox/hello@v1 --env devtest --gateways devtest,partner-local. After you revoke a certificate with weikio gateway set partner-local --revoke-certificate test=partner.pem, the gateway rejects it once the change reaches it.

An internal entrance#

An entrance is a separate listener. Add one at install with weikio-backend init --dev --apim-entrance internal=127.0.0.1:8444, and start the gateway with both listeners. A gateway created with --entrance internal then answers only on 8444, while a gateway of the entrance public answers only on its port.

Limits across APIM instances#

Start a second gateway process against the same message server with WEIKIO_APIM_INSTANCE=2. Give it a WEIKIO_HOME and a port that the first process doesn’t use.

A subscription’s limit applies across both processes. When you stop one, the other keeps counting the same window.

A site gateway#

A site gateway’s APIM instance is one more gateway process. Start it from the gateway.env of its bundle, against the message server beside it on the laptop.

Sign in to the live demo

Sign in with the shared viewer account. It can open every screen of the example projects but can't change anything.

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