Skip to content

Commit

Permalink
Refactor request handling: rename and extract parameter preparation l…
Browse files Browse the repository at this point in the history
…ogic into a new function
  • Loading branch information
xiangnanscu committed Dec 28, 2024
1 parent 1833103 commit be3e347
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/resty/http.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 {})
Expand All @@ -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
Expand Down

0 comments on commit be3e347

Please sign in to comment.