lib/sensu/api/http_handler.rb
# Paginate the provided items. This method uses two HTTP query
# parameters to determine how to paginate the items, `limit` and
# `offset`. The parameter `limit` specifies how many items are
# to be returned in the response. The parameter `offset`
# specifies the items array index, skipping a number of items.
# This method sets the "X-Pagination" HTTP response header to a
# JSON object containing the `limit`, `offset` and `total`
# number of items that are being paginated.
#
# @param items [Array]
# @return [Array] paginated items.
Paginate the provided items. This method uses two HTTP query
parameters to determine how to paginate the items, `limit` and
`offset`. The parameter `limit` specifies how many items are
to be returned in the response. The parameter `offset`
specifies the items array index, skipping a number of items.
Paginate the provided items . This method uses two HTTP query parameters to determine how to paginate the items ` limit ` and ` offset ` . The parameter ` limit ` specifies how many items are to be returned in the response . The parameter ` offset ` specifies the items array index skipping a number of items .
def pagination(items)
        limit = integer_parameter(@params[:limit])
        offset = integer_parameter(@params[:offset]) || 0
        unless limit.nil?
          @response.headers["X-Pagination"] = Sensu::JSON.dump(
            :limit => limit,
            :offset => offset,
            :total => items.length
          )
          paginated = items.slice(offset, limit)
          Array(paginated)
        else
          items
        end
      end
def pagination ( items ) limit = integer_parameter ( @params [ :limit ] ) offset = integer_parameter ( @params [ :offset ] ) || 0 unless limit . nil? @response . headers [ "X-Pagination" ] = Sensu :: JSON . dump ( :limit => limit , :offset => offset , :total => items . length ) paginated = items . slice ( offset , limit ) Array ( paginated ) else items end end
Paginate the provided items.
Paginate the provided items .
None
Array
items
None