From be3e3478024bcdc6ae975afdafc1e67160914965 Mon Sep 17 00:00:00 2001 From: xiangnan <280145668@qq.com> Date: Sat, 28 Dec 2024 21:03:16 +0800 Subject: [PATCH] Refactor request handling: rename and extract parameter preparation logic into a new function --- lib/resty/http.lua | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/resty/http.lua b/lib/resty/http.lua index a85f85a..99c5181 100644 --- a/lib/resty/http.lua +++ b/lib/resty/http.lua @@ -903,8 +903,7 @@ function _M.request_pipeline(self, requests) return responses end - -function _M.request_uri(self, uri, params) +function _M.prepare_request_params(self, uri, params) params = tbl_copy(params or {}) -- Take by value if self.proxy_opts then params.proxy_opts = tbl_copy(self.proxy_opts or {}) @@ -931,6 +930,15 @@ function _M.request_uri(self, uri, params) end end + return params +end + +function _M.request_uri(self, uri, params) + local params, err = self:prepare_request_params(uri, params) + if not params then + return nil, err + end + local ok, err = self:connect(params) if not ok then return nil, err