https://www.krakend.io/
https://github.com/devopsfaith/krakend-examples
https://github.com/devopsfaith/krakendesigner

{
  "version": 2,
  "name": "",
  "port": 8000,
  "timeout": "3s",  // 也可放在endpoint中,单独限制
  "tls": {
    "public_key": "/path/to/cert.pem",
    "private_key": "/path/to/key.pem"
  }
  "endpoints": [
    "endpoint": "/api/v1/foo-bar",
    "method": "GET",
    "timeout": "800ms",
    "concurrent_calls": 3,  // 一般不配置,和负载host两码事,这是并发向一个后端请求,择其快者
    "headers_to_pass": ["Authorization", "Content-Type"]
    "extra_config": {
      "maxRate": 5000, // ==0不限制!针对该endpoint的qps
      "clientMaxRate": 0,  // ==0不限制!针对每一个client(ip)的qps
      "strategy": "header",  // 默认按照ip来区分client

      "key": "X-Auth-Token"  // 按照header中的该key来鉴定一个client
    },
    "headers_to_pass": [ // 向下游传递哪些Headers,"*"表所有
      "Cookies"  // 默认传递"Host","User-Agent","Accept-Encoding","X-Forward-For
    ],
    "querystring_params":[ // 向下游传递哪些请求参数
      "a", "b"  // 只是指定那些key的参数可以向后传递,若实际没有传递则还是没有; "*"表传递所有
    ]
    // 添加多个backend会自动merge
    // header中指示是否全部完成: X-Krakend-Completed: false
    "backend": [
      {
        "url_pattern": "/users/{user}?name={name}"  // /users/1?name=lei,强制带参数,否则返回404.除非指定querystring,此时可不指定name(自动使用前面的值)
        "host": ["http://127.0.0.1:8000"],
        "encoding": "json",  // 改变原来的编码格式,xml,rss
        "group": "newkeyname",  // merge时作为rsp中一个单独的keyname
        "target": "data",  // 剥离原返回中的data键,里面的value作为根
        "mapping": {
          "email": "personal_email"  // 修该rsp中的key
        }
      }
      {
        "url_pattern": "/foo",
        "extra_config": {
          "github.com/devopsfaith/krakend-circuitbreaker/gobreaker": {
            "interval": 60,  // 60s后端调用失败4次,后面的所有调用都延迟10s
            "maxErrors": 4,  // 当有任何一次成功时,线路恢复
            "timeout": 10,
            "logStatusChange": true
          },
          "github.com/devopsfaith/krakend/proxy": {
            "shadow": true  // 方便新接口线上测试,会copy一份req,当并不会rsp给client
          }
        }
      }
    ]
  ]
}