Middleware engine for AWS Lambda - Inspired by middyjs
Project description
PyMiddy
Heavily inspired from middyjs.
Quick start
from pymiddy import Middy
from pymiddy.middlewares import CORS
@Middy
def handler(event, context):
return {
'statusCode': 200,
'body': 'lorem ipsum dolor sit amet'
}
handler.use(TestMiddleware(1)) \
.use(CORS({
'credentials': True,
'origins': ['https://website.xyz/']
}))
Custom middlewares
A middleware class should have 3 methods:
class MyCustomMiddleware(object):
def before(self, state):
pass
def after(self, state):
pass
def error(self, state):
pass
The state contains the following keys:
event- the event which triggered the lambda function, passed from the aws handlercontext- the context from the aws handlerresponse- the handler response, if anyexception- during error handler you can have access to this key which contains the exception which triggered the error
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymiddy-0.1.0.tar.gz
(2.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pymiddy-0.1.0.tar.gz.
File metadata
- Download URL: pymiddy-0.1.0.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
288dbf3c1b413bfbcb2f2a0b08dec2dcda48bebf3f8728d2897231a011cd4b5b
|
|
| MD5 |
968bf2cc15e10674ef3c28b7ac7c8783
|
|
| BLAKE2b-256 |
7be6feed7a517fc035e45d79bca010248ca3cb9e57498de7c7dac1833ea1ce6f
|
File details
Details for the file pymiddy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pymiddy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.33.0 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
388b06a3e095fd6821d8e9dfe2ecba980d9c63a39180fc65abca81d359bdd011
|
|
| MD5 |
1fe0b0666522ea12b45bb644fa5461b1
|
|
| BLAKE2b-256 |
f5c0e45efea934b30e78daab1fd83086b00d67ce25b3a94a47f51149187c9476
|