Skip to main content

A flexible AWS Lambda event router with support for multiple event sources

Project description

Lambda Universal Router

PyPI version Python Support License Documentation

A flexible and type-safe router for AWS Lambda functions that supports multiple event sources. This library makes it easy to handle different types of AWS Lambda events in a clean and organized way.

Documentation

📚 Full Documentation

Features

  • 🎯 Type-safe event handling with proper Python type hints
  • 🔄 Support for multiple AWS event sources
  • 🎨 Clean decorator-based routing
  • 📦 Easy to extend with new event sources
  • 🔒 Structured event objects with proper typing
  • 🔍 Custom event handler support for unknown event types

Installation

pip install lambda-universal-router

Quick Start

from lambda_universal_router import Router
from lambda_universal_router.events import APIGatewayEvent, SQSEvent, CustomEvent

router = Router()

@router.apigateway("/hello", method="GET")
def hello(event: APIGatewayEvent, context):
    name = event.query_string_parameters.get('name', 'World')
    return {
        "statusCode": 200,
        "body": f"Hello, {name}!"
    }

@router.sqs()
def process_queue(event: SQSEvent, context):
    for msg in event.records:
        print(f"Processing message {msg.message_id}: {msg.body}")

@router.custom()
def handle_unknown(event: CustomEvent, context):
    print(f"Handling unknown event type: {event.event_data}")

def lambda_handler(event, context):
    return router.dispatch(event, context)

Supported Event Sources

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

See our Contributing Guide for more details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

See CHANGELOG.md for a list of changes and version history.

Project details


Download files

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

Source Distribution

lambda_universal_router-1.0.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lambda_universal_router-1.0.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file lambda_universal_router-1.0.0.tar.gz.

File metadata

  • Download URL: lambda_universal_router-1.0.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for lambda_universal_router-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2a086d5f9966731b4348ce1ca40fd3963c3029acc1d07290b5788343a4073a4f
MD5 10f4c90e03cc64fe8ad341e4d5162c49
BLAKE2b-256 b05eca5b8b22bbef52ae4d190192e971c5d33d329799e9c67c67e9faef6f47f4

See more details on using hashes here.

File details

Details for the file lambda_universal_router-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for lambda_universal_router-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c30a4d806804ba02b1270178e2a5e82eb648bb8d470d3f9e138609334ec9dab
MD5 7c2044a552d2fc937cb0f8166d04bfb2
BLAKE2b-256 b8d4283eed06c542cebbfa929f7fde6425e56edd718db24672512f0d02101cba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page