Skip to main content

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 handler
  • context - the context from the aws handler
  • response - the handler response, if any
  • exception - during error handler you can have access to this key which contains the exception which triggered the error

Release files for pymiddy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymiddy 0.1.0
File Size Uploaded
pymiddy-0.1.0.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pymiddy 0.1.0
File Interpreter ABI Platform
pymiddy-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 7.1 kB

Release files / pymiddy-0.1.0.tar.gz

Download URL pymiddy-0.1.0.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
288dbf3c1b413bfbcb2f2a0b08dec2dcda48bebf3f8728d2897231a011cd4b5b
BLAKE2b-256 checksum
How to use checksums
7be6feed7a517fc035e45d79bca010248ca3cb9e57498de7c7dac1833ea1ce6f
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / pymiddy-0.1.0-py3-none-any.whl

Download URL pymiddy-0.1.0-py3-none-any.whl
Size 4.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
388b06a3e095fd6821d8e9dfe2ecba980d9c63a39180fc65abca81d359bdd011
BLAKE2b-256 checksum
How to use checksums
f5c0e45efea934b30e78daab1fd83086b00d67ce25b3a94a47f51149187c9476
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page