You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/06/10 05:59:42 UTC
[GitHub] [incubator-apisix] zheng11581 opened a new issue #1682: request help:
zheng11581 opened a new issue #1682:
URL: https://github.com/apache/incubator-apisix/issues/1682
### Issue description
Use `filter_fun` problem.
1. My config is
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uris": ["/api/*"],
"methods": ["GET", "POST"],
"filter_func": "function(vars)
return vars['arg_a1'] == 'a1' and vars['arg_a2'] == 'a2'
end",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:20608": 1
}
}
}'
2. curl -i "http://127.0.0.1:9080/api/index?a1=a1&a2=a2"
HTTP/1.1 500 Internal Server Error
Date: Wed, 10 Jun 2020 05:55:12 GMT
Content-Type: text/html
Content-Length: 174
Connection: close
Server: APISIX web server
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>openresty</center>
</body>
</html>
3. error.log
2020/06/10 13:55:12 [error] 20344#20344: *34173910 lua entry thread aborted: runtime error: [string "router#1"]:2: invalid argument, expect string value
stack traceback:
coroutine 0:
[C]: in function 'error'
/usr/local/apisix/apisix/core/ctx.lua:68: in function '__index'
[string "router#1"]:2: in function 'filter_fun'
/usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:531: in function 'match_route_opts'
/usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:550: in function '_match_from_routes'
/usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:582: in function 'match_route'
/usr/local/apisix//deps/share/lua/5.1/resty/radixtree.lua:614: in function 'dispatch'
/usr/local/apisix/apisix/http/router/radixtree_uri.lua:110: in function 'match'
/usr/local/apisix/apisix/init.lua:285: in function 'http_access_phase'
access_by_lua(nginx.conf:168):2: in main chunk, client: 127.0.0.1, server: , request: "GET /api/index?a1=a1&a2=a2 HTTP/1.1", host: "127.0.0.1:9080"
### Environment
* apisix version (cmd: `apisix version`): 1.3
* OS: centos 7
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-apisix] zheng11581 commented on issue #1682: request help:
Posted by GitBox <gi...@apache.org>.
zheng11581 commented on issue #1682:
URL: https://github.com/apache/incubator-apisix/issues/1682#issuecomment-641767449
Ok,it works fine. thanks
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-apisix] membphis commented on issue #1682: request help:
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1682:
URL: https://github.com/apache/incubator-apisix/issues/1682#issuecomment-641745660
@zheng11581 I try to run your case with test cases, it works fine. I will make a try at my local machine.
https://github.com/apache/incubator-apisix/pull/1683
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-apisix] membphis closed issue #1682: request help:
Posted by GitBox <gi...@apache.org>.
membphis closed issue #1682:
URL: https://github.com/apache/incubator-apisix/issues/1682
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-apisix] membphis commented on issue #1682: request help:
Posted by GitBox <gi...@apache.org>.
membphis commented on issue #1682:
URL: https://github.com/apache/incubator-apisix/issues/1682#issuecomment-641752470
![image](https://user-images.githubusercontent.com/6814606/84233730-7a2b0200-ab25-11ea-9f2c-fc0eee59e919.png)
You can make a try with this:
```shell
$ curl -i http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"uris": ["/hello"],
"filter_func": "function(vars)
return vars[\"arg_a1\"] == \"a1\" and vars[\"arg_a2\"] == \"a2\"
end",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}
}'
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org