Sha256: def2840e4e3b8b3819e88725b1fe9c14f953c73cb3e20655bc34293c24fe3ce3
Contents?: true
Size: 656 Bytes
Versions: 6
Compression:
Stored size: 656 Bytes
Contents
module Rooftop class PaginationMiddleware < Faraday::Response::Middleware def on_complete(env) @env = env pagination = { total_count: header("x-wp-total").to_i, total_pages: header("x-wp-totalpages").to_i, per_page: (header("x-wp-per-page").to_i || 10), page: header("x-wp-page").to_i || 1 } env[:body].merge!(pagination: pagination) end private # Returns a response header value. # # @param [String] name of the header attribute # @return [String] the response header value def header(name) @env.response_headers[name] end end end
Version data entries
6 entries across 6 versions & 1 rubygems