Skip to content

neetjn/falcon-pagination-processor

Repository files navigation

falcon-pagination-processor

build codecov

PyPI version

Pagination middleware for falcon framework. Pulled from py-blog project @ https://github.com/neetjn/py-blog

About

falcon-pagination-processor is a very simple middlware for the Falcon Web/REST framework for Python. This middleware provides pagination details in each request context based on the provided query parameters.

Use

This project should be compaitable with any version of Falcon. Support is available for both Python 2.7 and 3.4+.

falcon-pagination-processor can be installed with pip like so:

pip install falcon-pagination-processor

Once installed, the middleware can be instantiated extending the Falcon api:

import falcon
from falcon_pagination_processor import PaginationProcessor


api = falcon.API(middleware=[PaginationProcessor()])

Pull pagination details from requests like so:

def get_resources(start, count):
    """Get paginated list of resources"""
    if start and count:
        return Resources[start:start+count]
    return Resources


class TestResourceCollection(object):


    def on_get(self, req, resp):
        pagination = req.context.get('pagination')
        res = get_resources(start=pagination.get('start'),
                            count=pagination.get('count'))

The pagination middleware looks for the start and count query parameters:

http://uri?start=1&count=5

Contributors

Contributing guidelines are as follows,

  • Any new features added must also be unit tested in the tests subdirectory.
    • Branches for bugs and features should be structured like so, issue-x-username.
  • Include your name and email in the contributors list.

Copyright (c) 2019 John Nolette Licensed under the MIT license.

About

Pagination middleware for falcon framework. Pulled from py-blog project @ https://github.com/neetjn/py-blog

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages