Skip to main content

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 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

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

pymiddy-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

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

pymiddy-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

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

Hashes for pymiddy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 288dbf3c1b413bfbcb2f2a0b08dec2dcda48bebf3f8728d2897231a011cd4b5b
MD5 968bf2cc15e10674ef3c28b7ac7c8783
BLAKE2b-256 7be6feed7a517fc035e45d79bca010248ca3cb9e57498de7c7dac1833ea1ce6f

See more details on using hashes here.

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

Hashes for pymiddy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 388b06a3e095fd6821d8e9dfe2ecba980d9c63a39180fc65abca81d359bdd011
MD5 1fe0b0666522ea12b45bb644fa5461b1
BLAKE2b-256 f5c0e45efea934b30e78daab1fd83086b00d67ce25b3a94a47f51149187c9476

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