Skip to content

Commit

Permalink
change /get_packs to not send everything
Browse files Browse the repository at this point in the history
  • Loading branch information
Bauumm committed Feb 5, 2024
1 parent 3b0f7a7 commit 6662313
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions server/web_api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,24 @@ app.handlers["/get_pack_preview_data/.../..."] = function(captures, headers)
return json.encode(result)
end

app.handlers["/get_packs"] = function(_, headers)
local pack_list = {}
app.handlers["/get_packs/.../..."] = function(captures, headers)
headers["content-type"] = "application/json"
return json.encode(packs)
local start = tonumber(captures[1])
local stop = tonumber(captures[2])
local last_index
for i = 1, stop - start + 1 do
local index = i + start - 1
if not packs[index] then
break
end
pack_list[i] = packs[index]
last_index = i
end
while pack_list[last_index + 1] do
pack_list[#pack_list] = nil
end
return json.encode(pack_list)
end

app.handlers["/get_pack/.../..."] = function(captures, headers)
Expand Down

0 comments on commit 6662313

Please sign in to comment.