Provide total record count in the metadata section
Closed this issue · 3 comments
Hey, @dang03
In order to implement pagination cleanly, one option is to get the total number of records on a given entity in the answer to a query.
What do you think? Do you already provide this, in a HTTP header, e.g.?
Please note that we're already using limit
(number of records per page, default 10
) and offset
(number of page, default 0
). For me, that total number of records should be the number of records that are present in the database, without forcing any limit.
Hi @jbonnet ,
Catalogues-Repos' answers provides pagination in the HTTP header, however it only implements limit
and offset
(set to 10
too), but no links to next or previous pages. Perhaps we can set X-total-count
header easily with the total number of records.
Would this be useful to you or you prefer to have the total record count in other way?
Hi!
Yes, it is fine. I have tested it and it only requires a minor tweak on each descriptor type APIs.
Here is an example for functions:
curl -X GET HEAD -i -H "Content-Type: application/json" "http://0.0.0.0:4011/catalogues/api/v2/vnfs"
HTTP/1.1 200 OK
Content-Type: text/html;charset=utf-8
Record-Count: 22
...others...
Content-Length: 11072
So it will be available for this new release.