Skip to content

ApiConfig

Thiago da Rosa de Bustamante edited this page Mar 27, 2018 · 3 revisions

This is the Api config descriptor. It supports following properties:

Property Type Description Required
id string The API identifier. If not provided during API creation, an uuid is used. false
name string The API name. true
version string The API version. More than one version can be published for the same API name. true
path string The path where the gateway will listen for requests that should be proxied for the current API. true
description string An optional description for API. false
group Group[] Configure groups of endpoints. false
proxy Proxy Configure the proxy engine for this API. true
authentication AuthenticationConfig[] Configure authentication for this API. false
throttling ThrottlingConfig[] Configure rate limits for this API. false
cache CacheConfig[] Configure cache for this API. false
circuitBreaker CircuitBreakerConfig[] Configure a circuit breaker for this API. false
cors ApiCorsConfig[] Configure cors support for this API. false
filter Filter[] A List of request filters to be added, in order, to the request pipeline. false
errorHandler MiddlewareConfig[] An ErrorHandler middleware to be called to handle any error during request pipeline processing for this API. false
interceptor Interceptors Configure request and response interceptors to be added to the request pipeline. false
disableAnalytics boolean Disable all request log recording for this API. false
parseReqBody string or Array<string> or boolean Allows you to control when to parse the request body. Just enable it if you need to access the request.body inside a proxy middleware, like a filter or interceptor. If disabled, the request is streamed to the target API, increasing performance. You can inform the expected types of body you are expecting: ["json", "urlencoded", "raw"]. Defaults to false. false
parseCookies boolean Allows you to control when to parse the request cookies. Just enable it if you need to access the request.cookies inside a proxy middleware, like a filter or interceptor. Defaults to false. false

Example:

{
    "name": "TestAPI",
    "version": "1.0.0",
    "path": "test/",
    "proxy": {
        "target": {
            "host": "http://httpbin.org"
        },
        "timeout": 5000
    }
}

or,

---
name: TestAPI
version: 1.0.0
path: test/
proxy:
  target:
    host: http://httpbin.org
  timeout: 5000

That configuration will map any request to the base path /test to be proxied to http://httpbin.org.

For example, the given URLs:

  • http://localhost:8000/test/get will point to http://httpbin.org/test/get
  • http://localhost:8000/test/get?param=1 will point to http://httpbin.org/test/get?param=1

Assuming that your gateway is running on http://localhost:8000.

Group

Groups allow you to organize your configurations. They can be referenced by other API configurations, like throttling, cache (and others) to define behaviors that only apply to a specific set of endpoints.

The Group configuration supports the following properties:

Property Type Description Required
id string The Group identifier. true
member Member[] A list of group members. true
description string An optional description for the group. false

Member

Configure a member of a Group.

It supports the following properties:

Property Type Description Required
path string[] A list of request paths that belong to the group. Support glob patterns false
member string[] A list of HTTP methods that belong to the group. false
protocol string[] A list of protocols that belong to the group. false

Example:

{
    "name": "TestAPI",
    "version": "1.0.0",
    "path": "test/",
    "group": [
        {
            "id": "Group1",
            "description": "Endpoints Group One",
            "member": [
                {
                    "path": ["get"], 
                    "method": ["GET"]
                }, 
                {
                    "path": ["post"], 
                    "method": ["GET"]
                }
            ] 
        },
        {
            "id": "Group2",
            "description": "Endpoints Group Two",
            "member": [
                {
                    "path": ["user-agent"] 
                }, 
                {
                    "method": ["POST"]
                }
            ] 
        }
    ],
    "proxy": {
        "target": {
            "host": "http://httpbin.org",
            "allow": ["Group1"],
            "deny": ["Group2"]
        },
        "timeout": 5000
    }
}

or

---
name: TestAPI
version: 1.0.0
path: test/
group:
- id: Group1
  description: Endpoints Group One
  member:
  - path:
    - get
    method:
    - GET
  - path:
    - post
    method:
    - GET
- id: Group2
  description: Endpoints Group Two
  member:
  - path:
    - user-agent
  - method:
    - POST
proxy:
  target:
    host: http://httpbin.org
    allow:
    - Group1
    deny:
    - Group2
  timeout: 5000

This example show how to use groups to define rules for the proxy engine allowing or denying requests that should target the configured API.

Clone this wiki locally