openresty 根据参数 重定向请求
来源:互联网 发布:charles mac 编辑:程序博客网 时间:2024/06/06 23:16
1、nginx配置文件增加配置节
location /a {
default_type 'text/html';
lua_code_cache on;
rewrite_by_lua_file /data/lua/a.lua;
}
location @b {
default_type 'text/html';
lua_code_cache on;
content_by_lua_file /data/lua/b.lua;
}
location @c {
default_type 'text/html';
lua_code_cache on;
content_by_lua_file /data/lua/c.lua;
}
vi a.lua
ngx.req.read_body()
local args, err = ngx.req.get_post_args()
if args["t1"]==nil then
ngx.req.set_uri_args("t1=ccc")
ngx.exec("@b")
else
ngx.req.set_uri_args("t1=ccc")
ngx.exec("@c")
end
vi b.lua
ngx.req.read_body()
local args, err = ngx.req.get_post_args()
ngx.say("b")
ngx.say(ngx.var.arg_t1)
ngx.say(args["t1"])
ngx.say(ngx.req.get_headers()["AAA"])
vi c.lua
ngx.req.read_body()
local args, err = ngx.req.get_post_args()
ngx.say("c")
ngx.say(ngx.var.arg_t1)
ngx.say(args["t1"])
ngx.say(ngx.req.get_headers()["AAA"])
--[[
分别显示post,get参数和header信息
]]--
模拟发送请求,携带和不携带POST参数,显示不同的结果。
- openresty 根据参数 重定向请求
- 读取请求参数、向页面传值、重定向
- 请求重定向并且传递参数的方式
- 关于SpringMVCController层请求重定向携带参数的处理
- springmvc-请求转发重定向(携带参数)
- 请求转发 重定向
- response请求重定向
- 请求重定向
- twisted09 请求重定向
- 请求重定向
- ajax请求重定向
- 实现请求重定向
- 请求重定向
- Servlet请求重定向
- 请求重定向
- 重定向&请求转发
- 网络请求重定向
- ajax请求重定向
- JFrame设置最大尺寸
- 统计学习方法--条件随机场1
- Learning Python 004 基础的数据类型和变量
- C#下载文件
- VS环境下Debug和Release版本的区别
- openresty 根据参数 重定向请求
- 记录下我使用的UI
- IOS常见的加密方式
- ng $watch
- 思维导图整理
- 96. Unique Binary Search Trees
- 136. Single Number
- POJ 1182 食物链 节点与树根记录下关系的并查集(种类并查)
- html5 运行在手机上 图片根据手势缩放