apisix icon indicating copy to clipboard operation
apisix copied to clipboard

how to use vars in routes?

Open zhuchengxing opened this issue 6 years ago • 1 comments

Issue description

1. I add a new route: { "methods": [ "POST" ], "uris": [ "/test" ], "vars": [["arg_age","==","20"] ], "upstream": {

    "nodes": {
        "10.3.155.39:8080": 1
    },
    "type": "roundrobin"
}

}

  1. curl -i http://127.0.0.1:9080/api/index -X POST -d '{age:"20", arg_age:"20"}'

  2. {"error_msg":"404 Route Not Found"}

Environment

  • apisix version (cmd: apisix version):2.0
  • OS:centos7.3

zhuchengxing avatar Nov 16 '20 11:11 zhuchengxing

The arg_age variable is for the query parameter in the URI (?age=xxx). http://nginx.org/en/docs/http/ngx_http_core_module.html#variables

To route according to the sent JSON body you should write your filter function: https://github.com/api7/lua-resty-radixtree/#new

spacewander avatar Nov 16 '20 11:11 spacewander