Skip to main content

AWS Lambda Routing Utility

Project description

lambda_router: Python Helpers for AWS Lambdas

lambda_router is a Python package that provides a few helpers for writing Python-based AWS Lambda functions.

Its main goal is to reduce the boilerplate code when writing lambda functions that need to handle multiple routes.

Getting Started

Install with:

    $ pip install lambda_router

Creating a basic, single-route app:

    import lambda_router


    config = lambda_router.Config()
    # Load all environment variables prefix with JSR_.
    config.load_from_environment(prefix="JSR_")
    app = lambda_router.App(name="example_lambda", config=config)


    app.route()
    def main(event):
        # This is the main route of your lambda
        return {"message": "success"}

Or a multi-route app that uses the type field in the lambda event for routing:

    import lambda_router


    config = lambda_router.Config()
    # Load all environment variables prefix with JSR_.
    config.load_from_environment(prefix="JSR_")
    app = lambda_router.App(name="example_lambda", config=config, route=lambda_router.routers.EventField(key="type"))


    app.route("route_one")
    def main(event):
        return {"message": "success from route_one"}

    app.route("route_two")
    def main(event):
        return {"message": "success from route_two"}

Contributing

Use pipenv to install the dev requirements:

    $ pipenv install --dev

Install the git pre-commit hooks:

    $ pipenv run pre-commit install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for lambda-router, version 2020.1.1
Filename, size File type Python version Upload date Hashes
Filename, size lambda_router-2020.1.1-py2.py3-none-any.whl (8.8 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page