Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4489 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2010-12-11 13:13:49 +00:00
parent 67f1131a20
commit 00d50157d3
9 changed files with 109 additions and 19 deletions

View File

@@ -349,6 +349,23 @@ class ApplicationController < ActionController::Base
per_page
end
def api_offset_and_limit
offset = nil
if params[:offset].present?
offset = params[:offset].to_i
if offset < 0
offset = 0
end
end
limit = params[:limit].to_i
if limit < 1
limit = 25
elsif limit > 100
limit = 100
end
[offset, limit]
end
# qvalues http header parser
# code taken from webrick
def parse_qvalues(value)