-
Notifications
You must be signed in to change notification settings - Fork 44
APIs Configuration
The gateway configurations are persisted inside the redis database and can be altered through the Admin REST API, Node SDK or CLI tool.
Lets show here how to manage APIs into the gateway using the CLI tool.
To configure an API under the gateway, you need to create a configuration file. You can configure it using YAML or JSON. For example, lets create a file called test.yaml:
---
name: Test
version: 1.0.0
path: "/test"
proxy:
target:
host: http://httpbin.org
timeout: five secondsAnd use the Tree Gateway CLI to configure it into the gateway:
treeGatewayConfig apis --add ./test.yamlAnd its done. You can test it accessing in your browser: http://localhost:8000/test/get
If you open your test.yaml file, you will see that an ID was added to the configuration. This ID is created if you do not provide one in your configuration.
---
name: Test
version: 1.0.0
path: "/test"
proxy:
target:
host: http://httpbin.org
timeout: five seconds
id: 5a69e1f8cbeed907f6acb328Take a look at ApiConfig to learn more about the api configuration file.
To see the APIs configured, use the CLI as:
treeGatewayConfig apis --listIf you want to filter the results, you can add those filters to the command. Ex:
treeGatewayConfig apis --list name:testOnly configurations that has a name starting with test will be listed.
You can add more filters:
treeGatewayConfig apis --list name:test version:1.0.0To retrieve a configuration for a given API, run the command:
treeGatewayConfig apis --get 5a69e1f8cbeed907f6acb328 > test.yamlThat command will retrieve the configuration for the API with the id 5a69e1f8cbeed907f6acb328 and save it to the file test.yaml.
if you prefer to export the configuration as json, run:
treeGatewayConfig apis --get 5a69e1f8cbeed907f6acb328 json > test.jsonJust edit the config file you retrieved previously and then run the command
treeGatewayConfig apis --update test.yamlor
treeGatewayConfig apis --update test.jsonRun the command:
treeGatewayConfig apis --remove 5a69e1f8cbeed907f6acb328That will remove the API with id 5a69e1f8cbeed907f6acb328