<<

NAME

Koha::REST::Plugin::Pagination

API

Mojolicious::Plugin methods

register

Helper methods

add_pagination_headers

    $c->add_pagination_headers();
    $c->add_pagination_headers(
        {
            base_total   => $base_total,
            page         => $page,
            per_page     => $per_page,
            query_params => $query_params,
            total        => $total,
        }
    );

Adds RFC5988 compliant Link headers for pagination to the response message carried by our controller.

Additionally, it also adds the customer X-Total-Count header containing the total results count, and X-Base-Total-Count header containing the total of the non-filtered results count.

Optionally accepts the any of the following parameters to override the values stored in the stash by the search_rs helper.

base_total

Total records for the search domain (e.g. all patron records, filtered only by visibility)

page

The requested page number, usually extracted from the request query. See objects.search_rs for more information.

per_page

The requested maximum results per page, usually extracted from the request query. See objects.search_rs for more information.

query_params

The request query, usually extracted from the request query and used to build the Link headers. See objects.search_rs for more information.

total

Total records for the search with filters applied.

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.

<<