编写这个插件前, 会用到上一篇里提到的/internal_api这里不太赘述. 结合ngx.location.capture_multi API, 我们可以写出如下的代码: handler.lua -- handler.lualocalBasePlugin=require"kong.plugins.base_plugin"localGGHandler=BasePlugin:extend()GGHandler.VERSION="1.0.0"GGHandler.PRIORITY=10functionGGHandler:a...
51CTO博客已为您找到关于ngx.location.capture_multi的相关内容,包含IT学习相关文档代码介绍、相关教程视频课程,以及ngx.location.capture_multi问答内容。更多ngx.location.capture_multi相关解答可以来51CTO博客参与分享和学习,帮助广大IT技术人实现成长和进步。
ngx.ctx #这是一个lua的table,用于保存ngx上下文的变量,在整个请求的生命周期内都有效,详细参考官方 ngx.location.capture() #发出一个子请求,详细用法参考官方文档。 ngx.location.capture_multi() #发出多个子请求,详细用户参考官方文档。 ngx.status #读或者写当前请求的相应状态,必须在输出相应头之前被调用。
ngx.var['arg_a'] 取queryString的参数a #/nginx_var?a=hello,world ngx.say(...) 依次输出参数,带换行 ngx.print(...) 格式化输出,不带换行 ngx.var.name 取nginx里的name变量,如ngx.var.remote_addr locale res = ngx.location.capture() 请求内部location ngx.location.capture_multi() 同时请求多个...
ngx.location.capture_multi 语法:res1,res2, ... = ngx.location.capture_multi({ {uri, options?}, {uri, options?}, ...}) 与ngx.location.capture功能一样,可以并行的、非阻塞的发出多个子请求。这个方法在所有子请求处理完成后返回,并且整个方法的运行时间取决于运行时间最长的子请求,并不是所有子请求...
location /bar { echo bar; } 输出: [plain]view plaincopyprint? $ curl location/main $ foo bar 这里,main location就是发送2个子请求,分别到foo和bar,这就类似一种函数调用。 “子请求”方式的通信是在同一个虚拟主机内部进行的,所以 Nginx 核心在实现“子请求”的时候,就只调用了若干个 C 函数,完全不...
location /bar { echo bar; } 输出: $ curl location/main $ foo bar 这里,main location就是发送2个子请求,分别到foo和bar,这就类似一种函数调用。 “子请求”方式的通信是在同一个虚拟主机内部进行的,所以 Nginx 核心在实现“子请求”的时候,就只调用了若干个 C 函数,完全不涉及任何网络或者 UNIX 套接...
locale res = ngx.location.capture() 请求内部location ngx.location.capture_multi() 同时请求多个内部location res.status 取上面请求返回的状态 取值为常量: ngx.HTTP_OK = 200 ngx.HTTP_FORBIDDEN ngx.HTTP_INTERNAL_SERVER_ERROR ... ... res.body 去上面请求反回的页面内容 ...
http method constans: #经常在ngx.location.catpure和ngx.location.capture_multi方法中被调用. ngx.HTTP_GET ngx.HTTP_HEAD ngx.HTTP_PUT ngx.HTTP_POST ngx.HTTP_DELETE ngx.HTTP_OPTIONS ngx.HTTP_MKCOL ngx.HTTP_COPY ngx.HTTP_MOVE ngx.HTTP_PROPFIND ...
location /foo { echo foo; } location /bar { echo bar; } 输出: [plain]view plaincopyprint? $ curl location/main $ foo bar 这里,main location就是发送2个子请求,分别到foo和bar,这就类似一种函数调用。 “子请求”方式的通信是在同一个虚拟主机内部进行的,所以 Nginx 核心在实现“子请求”的时候,...