Publish an API and call it
APIM 1 · 3:55
An HTTP service goes public through Weik.io's API gateway, and the first call returns its JSON. Publishing needs three documents, and the gateway lets no call through until a subscription allows it.
This part of the video couldn't be loaded.
What it covers
- The API, version and deployment documents for
invoices, a proxy to the upstream service - Publishing to production with
weikio apply, the deployment document included - An anonymous subscription for a first look
- A call to
api.example.comforwarded through the gateway to the upstream service - How the URL is built from the host name, the prefix, the version and the path
- The API's page in the admin UI, with its versions and subscriptions
Commands in this video
Terminal
$ weikio apply -f ./finance/apis/
$ weikio subscription create finance/first-look --env production --api invoices --type anonymous
$ curl http://api.example.com/invoices/1.0/orders/42Transcript
- 0:02This video publishes an HTTP service behind your Weik.io installation as an API,
- 0:08through its API gateway, and calls it.
- 0:15This is your Weik.io installation: the hub and the project finance.
- 0:21The hub runs the API gateway,
- 0:23which serves production on the gateway's host name, where orders-api runs.
- 0:28Nothing of the API invoices is published yet.
- 0:36The first document names the API invoices and its prefix on the gateway.
- 0:42The second is version 1.0, a proxy version that answers by forwarding the call.
- 0:48The routes and clusters are YARP's routing configuration, unchanged.
- 0:53A route takes every path under the version to a cluster holding the orders-api address.
- 0:59The third document deploys version 1.0 into production.
- 1:04A version answers only where a deployment puts it.
- 1:11weikio apply on the apis folder sends its documents to your Weik.io installation,
- 1:18to the project they name.
- 1:19Weik.io keeps each document as it keeps everything else.
- 1:23The same command remakes the gateway's routing for production from those documents.
- 1:30An API takes no calls until a subscription says who may call.
- 1:35weikio subscription create makes first-look for invoices, anonymous, in production.
- 1:41Writing into production is confirmed on the terminal,
- 1:44so this write passed on your yes.
- 1:47An anonymous subscription issues no credential,
- 1:50so the gateway admits calls that carry nothing.
- 1:57curl calls the published API from outside the installation,
- 2:01on the gateway's host name.
- 2:03The gateway matches this host name and path, finds the version a deployment put into production,
- 2:09and forwards the call to the address the cluster holds.
- 2:13orders-api answers, and its answer comes back through the gateway unchanged,
- 2:19so the caller gets the order as JSON.
- 2:24The address carries four pieces: where the gateway is,
- 2:28which API, which version and which path.
- 2:32It opens with the production gateway's host name, written by an administrator.
- 2:37The prefix picks invoices from the APIs that name serves.
- 2:42Then the version, which answers here because of the deployment.
- 2:46Below that, the route takes the API's path to orders-api.
- 2:54The API has a page in the admin UI, from the records the CLI wrote.
- 2:59Version 1.0 is served in production, at the address the Overview gives.
- 3:06Subscriptions lists first-look on production's gateway,
- 3:09a subscription that asks for no credential.
- 3:13The version's view covers the deployment,
- 3:16the route and the cluster holding the upstream address.
- 3:23The caller comes in at the left, and orders-api answers at the right.
- 3:29The three documents, applied once, gave the gateway what it serves now.
- 3:34The caller got orders-api's own answer back.
- 3:37Everything the caller needed was this address: the gateway's name,
- 3:42the API, the version, the path.
Next in this track
APIM 2 · 3:28 Open it to a caller: a key and a limit Watched