Skip to content
This repository was archived by the owner on Jun 18, 2024. It is now read-only.

Commit 62d3b06

Browse files
author
Adis Nezirovic
committed
MINOR/REORG: Use more descriptive variable names instead of "resp".
1 parent 4478a23 commit 62d3b06

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

acme.lua

+14-14
Original file line numberDiff line numberDiff line change
@@ -311,35 +311,34 @@ local function new_order(applet)
311311
end
312312

313313
-- Place new order
314-
resp, err = acme:post{url=acme.resources["newOrder"], data=order_payload,
314+
local order, err = acme:post{url=acme.resources["newOrder"], data=order_payload,
315315
resource="newOrder"}
316-
if not resp then
316+
if not order then
317317
return http.response.create{status_code=500, data=err}:send(applet)
318-
else if resp.status_code ~= 201 then
319-
return resp:send(applet)
318+
elseif order.status_code ~= 201 then
319+
return order:send(applet)
320320
end
321321

322-
local resp_json = resp:json()
323-
local finalize = resp_json.finalize
324-
local authorizations = resp_json.authorizations
322+
local order_json = order:json()
325323

326-
for _, auth in ipairs(authorizations) do
324+
for _, auth in ipairs(order_json.authorizations) do
327325
--
328326
local auth_payload = {
329327
keyAuthorization = nil
330328
}
331329

332330
-- Get auth token
333-
local resp, err = http.get{url=acme:proxy_url(auth)}
331+
local auth, err = http.get{url=acme:proxy_url(auth)}
334332

335-
if resp then
336-
local auth_resp = resp:json()
333+
if auth then
334+
local auth_json = auth:json()
337335

338-
for _, ch in ipairs(auth_resp.challenges) do
336+
for _, ch in ipairs(auth_json.challenges) do
339337
if ch.type == "http-01" then
340338
http_challenges[ch.token] = string.format("%s.%s",
341339
ch.token, acme.account.thumbprint)
342-
resp, err = acme:post{url=ch.url, data=ch, resource="challengeDone", timeout=1}
340+
resp, err = acme:post{url=ch.url, data=ch,
341+
resource="challengeDone", timeout=1}
343342
end
344343
end
345344
end
@@ -370,7 +369,8 @@ local function new_order(applet)
370369
csr = http.base64.encode(csr:tostring("DER"), base64enc)
371370
}
372371

373-
resp, err = acme:post{url=finalize, data=payload, resource="finalizeOrder"}
372+
resp, err = acme:post{url=order_json.finalize, data=payload,
373+
resource="finalizeOrder"}
374374

375375
if resp and resp.status_code == 200 then
376376
local resp_json = resp:json()

0 commit comments

Comments
 (0)