|
|
local modname= ...
|
|
|
local M={}
|
|
|
_G[modname]=M
|
|
|
package.loaded[modname]=M
|
|
|
local http_request = {}
|
|
|
|
|
|
|
|
|
--- 获取请求参数---
|
|
|
function M.get_req_param(req_param)
|
|
|
function http_request.get_req_param(req_param)
|
|
|
local args = nil
|
|
|
local err = nil
|
|
|
local http_req_method = ngx.var.request_method
|
...
|
...
|
@@ -36,15 +33,15 @@ end |
|
|
|
|
|
|
|
|
--- 获取请求的method
|
|
|
function M.get_method()
|
|
|
function http_request.get_method()
|
|
|
-- if miniapp, then method is miniappBrandM1 or miniappBrandM2
|
|
|
local business_line = self:get_req_param("business_line")
|
|
|
local business_line = get_req_param("business_line")
|
|
|
if (business_line == "miniappBrandM1") or (business_line == "miniappBrandM2") then
|
|
|
return business_line
|
|
|
end
|
|
|
-- if method existed, return method in request params
|
|
|
-- or method not existed , using PATH, for example: /operations/resource/get
|
|
|
local method = self:get_req_param("method")
|
|
|
local method = get_req_param("method")
|
|
|
if method then
|
|
|
return method
|
|
|
else
|
...
|
...
|
@@ -53,4 +50,5 @@ function M.get_method() |
|
|
|
|
|
end
|
|
|
|
|
|
return http_request
|
|
|
|
...
|
...
|
|