简体   繁体   中英

Krakend endpoint variable within extra config

I have to use an endpoint variable within extra-config Proxy Flatmap Filter arguments.

...
{
  "endpoint": "/cascade/{entity}/{id}/{subentity}/{commonField}",
  "backend": [
    {
      "url_pattern": "/api/{entity}/{id}",
      "host": ["http://myapi:8080/"],
      "encoding": "json",
      "extra_config": {
        "proxy": {
          "flatmap_filter": [
            {
              "type": "move",
              "args": ["{{commonField}}","customField"]
            }
          ]
        }
      }
    }
  ]
}
...

I need to get from url commonField and use it within flatmap filter as first value of args array. But this doesn't work. Is a kind of configuration constraint that I can't use URL variable anyware in the configs?

Although using variables from url_pattern in flatmap_filter is not possible out-of-the-box currently, you can always use Lua scripting or a request/response modifier plugin (using Golang) to achieve that transformations.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM