123456789101112131415161718 |
- -- 引入 cjson 库,用于处理 JSON 数据
- local cjson = require "cjson"
- -- 获取 URL 中的查询参数(GET 请求参数)
- local args = ngx.req.get_uri_args()
- -- 获取当前请求的所有请求头信息
- local request_headers = ngx.req.get_headers()
- -- 判断请求头中是否包含 "token" 字段,或者查询参数中是否包含 "token"、"data" 或 "amp;data"
- -- 如果满足任一条件,则执行以下操作:
- if request_headers["token"] or args["token"] or args["data"] or args["amp;data"] then
- -- 设置上下文中的 log_request 标志为 true,表示需要记录该请求
- ngx.ctx.log_request = true
- -- 读取请求体内容(用于后续可能的请求体处理,如日志记录或参数解析)
- ngx.req.read_body()
- end
|