Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

delphimvcframework-middleware-paginate

Middleware for paginate results using DelphiMVCFramework

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

<h1>DelphiMVCFramework Paginate Middleware</h2> Middleware for paginate results using DelphiMVCFramework

Prerequisites

This middleware is designed to work with Delphi MVC Framework.

Usage

To use this middleware, enable it calling MVCEngine.AddMiddleware(TMVCPaginateMiddleware.Create)

Pagination middleware must be before Compression, if present.

To activate pagination in your response you need to pass a header in your request:

X-Paginate = true;

To controll the paging you can set two params:

limit = X (defines the paging record limit)

page = X (informs which page should be returned)

Example

GET http://127.0.0.1:8080/api/products?page=1&limit=3

Response :

<pre><code> { "results": [ { "id": 1, "active": 1, "qtd": -12, "description": "FRITAS" }, { "id": 2, "active": 1, "qtd": -28, "description": "POLENTA" }, { "id": 3, "active": 1, "qtd": -3, "description": "CALABRESA + FRITAS" } ], "total": 79, "limit": 3, "page": 1, "pages": 27 } </code></pre>