Skip to content
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

fix(get): propagate next page size param #9029 #9503

Merged
merged 22 commits into from
Nov 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
503eb49
fix(get): propagate next page size param #9029
jacksjm Oct 7, 2022
4f4faf8
fix: change to use args.size only if is a number
jacksjm Oct 10, 2022
ddce936
fix(style): remove (...) on if
jacksjm Oct 11, 2022
3a5a988
Merge branch 'master' into fix/propagate-next
jacksjm Oct 17, 2022
9434302
Merge branch 'master' into fix/propagate-next
jacksjm Oct 20, 2022
bae6da6
Merge branch 'master' into fix/propagate-next
jacksjm Oct 21, 2022
e7e636f
Merge branch 'master' into fix/propagate-next
jacksjm Oct 26, 2022
d5b93e1
fix: includes %s on a fmt string
jacksjm Oct 26, 2022
30cea7c
Merge branch 'fix/propagate-next' of github.com:jacksjm/kong into fix…
jacksjm Oct 26, 2022
ff06fbf
chore: create unit test
jacksjm Oct 28, 2022
e22eba8
Merge branch 'master' into fix/propagate-next
jacksjm Oct 28, 2022
57e3fc0
fix: change to only valid nil value
jacksjm Oct 29, 2022
4750789
fix(get): propagate next page size param #9029
jacksjm Oct 7, 2022
fa355bb
fix: change to use args.size only if is a number
jacksjm Oct 10, 2022
7dce8df
fix(style): remove (...) on if
jacksjm Oct 11, 2022
862a2df
fix: includes %s on a fmt string
jacksjm Oct 26, 2022
5bc1959
chore: create unit test
jacksjm Oct 28, 2022
313c389
fix: change to only valid nil value
jacksjm Oct 29, 2022
66e96a5
Merge branch 'master' into fix/propagate-next
jacksjm Oct 31, 2022
ed435cb
fix: change test style
jacksjm Oct 31, 2022
6eb8099
Merge branch 'fix/propagate-next' of github.com:jacksjm/kong into fix…
jacksjm Oct 31, 2022
d0caef9
Merge branch 'master' into fix/propagate-next
fffonion Nov 1, 2022
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
10 changes: 8 additions & 2 deletions kong/api/endpoints.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,22 +304,28 @@ end
local function get_collection_endpoint(schema, foreign_schema, foreign_field_name, method)
return not foreign_schema and function(self, db, helpers)
local next_page_tags = ""
local next_page_size = ""

local args = self.args.uri
if args.tags then
next_page_tags = "&tags=" .. escape_uri(type(args.tags) == "table" and args.tags[1] or args.tags)
end

if args.size then
next_page_size = "&size=" .. args.size
end

local data, _, err_t, offset = page_collection(self, db, schema, method)
if err_t then
return handle_error(err_t)
end

local next_page = offset and fmt("/%s?offset=%s%s",
local next_page = offset and fmt("/%s?offset=%s%s%s",
schema.admin_api_name or
schema.name,
escape_uri(offset),
next_page_tags) or null
next_page_tags,
next_page_size) or null
jacksjm marked this conversation as resolved.
Show resolved Hide resolved

return ok {
data = data,
Expand Down
9 changes: 9 additions & 0 deletions spec/02-integration/04-admin_api/10-services_routes_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ for _, strategy in helpers.each_strategy() do
pages[i] = json
end
end)

it("propagate in next a page size", function()
jacksjm marked this conversation as resolved.
Show resolved Hide resolved
local res = client:get("/services",
{ query = { size = 3 }})
local body = assert.res_status(200, res)
local json = cjson.decode(body)

assert.equals("/services?offset=" .. ngx.escape_uri(json.offset) .. "&size=3", json.next)
end)
end)

describe("with no data", function()
Expand Down