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 2023/01/12 14:40:26 UTC
[GitHub] [apisix] ronething commented on issue #8673: APISIX文档里有介绍Script,请问这个怎么用啊
ronething commented on issue #8673:
URL: https://github.com/apache/apisix/issues/8673#issuecomment-1380464263
@swtseaman Hi, can you show steps to reproduce?
a simple usage is like below.
```shell
$ docker run -d -p 8080:80 --rm kennethreitz/httpbin
```
```shell
$ curl http://127.0.0.1:9180/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d '
{
"uri": "/*",
"hosts": [
"httpbin"
],
"script" : "local _M = {} \n function _M.access(api_ctx) \n ngx.log(ngx.INFO,\"hit access phase\") \n end \nreturn _M",
"upstream": {
"nodes": {
"127.0.0.1:8080": 1
},
"type": "roundrobin"
}
}'
```
```shell
$ curl http://127.0.0.1:9080/get -H 'Host: httpbin' -vvv
```
then you will see log like below.
```
2023/01/12 22:38:59 [info] 4000620#4000620: *23936 [lua] [string "route#1"]:3: phase_func(): hit access phase, client: 127.0.0.1, server: _, request: "GET /get HTTP/1.1", host: "httpbin"
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org