<<

NAME

Koha::REST::Plugin::Pagination

API

Mojolicious::Plugin methods

register

Helper methods

add_pagination_headers

    my $patrons = Koha::Patrons->search( ... );
    $c->add_pagination_headers({
        total  => $patrons->count,
        params => {
            _page     => ...
            _per_page => ...
            ...
        }
    });

Adds a Link header to the response message $c carries, following RFC5988, including the following relation types: 'prev', 'next', 'first' and 'last'. It also adds X-Total-Count, containing the total results count.

If page size is omitted, it defaults to the value of the RESTdefaultPageSize syspref.

dbic_merge_pagination

    $filter = $c->dbic_merge_pagination({
        filter => $filter,
        params => {
            page     => $params->{_page},
            per_page => $params->{_per_page}
        }
    });

Adds page and rows elements to the filter parameter.

Internal methods

_build_link

    my $link = _build_link( $c, { page => 1, per_page => 5, rel => 'prev' });

Returns a string, suitable for using in Link headers following RFC5988.

<<