flask like web framework for AWS Lambda
Project description
lambdarest
Python routing mini-framework for AWS Lambda with optional JSON-schema validation.
Features
lambda_handler
function constructor with built-in dispatcher- Decorator to register functions to handle HTTP methods
- Optional JSON-schema input validation using same decorator
Support the development ❤️
You can support the development by:
-
like this mug for example:
External articles / tutorials
-
devgrok.com: Create a Private Microservice Using an Application Load Balancer
Article about how to use lambdarest with AWS Application Load Balancer
-
rockset.com: Building a Serverless Microservice Using Rockset and AWS Lambda
Article about how to set up lambdarest in AWS infrastructure
Other articles? add them here
Installation
Install the package from PyPI using pip:
$ pip install lambdarest
Getting Started
This module helps you to handle different HTTP methods in your AWS Lambda.
from lambdarest import lambda_handler
@lambda_handler.handle("get")
def my_own_get(event):
return {"this": "will be json dumped"}
##### TEST #####
input_event = {
"body": '{}',
"httpMethod": "GET",
"resource": "/"
}
result = lambda_handler(event=input_event)
assert result == {"body": '{"this": "will be json dumped"}', "statusCode": 200, "headers":{}}
Documentation
See docs for documentation and examples covering amongst:
- Advanced usage example
- Query params
- Headers and MultiValueHeaders
- Routing
- Authorization Scopes
- Exception Handling
- AWS Application Load Balancer
- CORS
Anormal unittest behaviour with lambda_handler
singleton
Because of python unittests leaky test-cases it seems like you shall beware of this issue when using the singleton lambda_handler
in a multiple test-case scenario.
Tests
Use the following commands to install requirements and run test-suite:
$ pip install -e ".[dev]"
$ black tests/ lambdarest/
$ rm -f test_readme.py
$ pytest --doctest-modules -vvv
For more info see Contributing...
Changelog
See HISTORY.md
Contributors
Thanks for contributing!
@sphaugh, @amacks, @jacksgt, @mkreg, @aphexer, @nabrosimoff, @elviejokike, @eduardomourar, @devgrok, @AlbertoTrindade, @paddie, @svdgraaf, @simongarnier, @martinbuberl, @adamelmore, @sloev
And by the way, we have a Code Of Friendlyhood!
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
Built Distribution
Hashes for lambdarest-13.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6a9340862d928421c79eb7e8dfba2c3c8356e677a00f8265821a5d4e7451af4 |
|
MD5 | 73ffb1a8c0f9277dc14eac1915f55f1d |
|
BLAKE2b-256 | 0b338cd9b4f1fa64b232a3abf84273cd6a8c248d2390b1ed883b3b9c429c95ef |