Skip to content

Refactor request handling for better code reuse #326

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading