Skip to main content

mediate

Middleware for every occasion

Installation

mediate can be installed from PyPI

pip install mediate

Usage

@middleware

from mediate import middleware

def shout(call_next, name):
    return call_next(name.upper())

def exclaim(call_next, name):
    return call_next(name + "!")

@middleware(shout, exclaim)
def hello(name):
    print(f"Hello, {name}")
>>> hello("sam")
Hello, SAM!

Middleware

Middleware.bind

import mediate

middleware = mediate.Middleware()

@middleware
def shout(call_next, name):
    return call_next(name.upper())

@middleware
def exclaim(call_next, name):
    return call_next(name + "!")

@middleware.bind
def hello(name):
    print(f"Hello, {name}")
>>> hello("sam")
Hello, SAM!

Middleware.compose

import mediate

middleware = mediate.Middleware()

@middleware
def shout(call_next, name):
    return call_next(name.upper())

@middleware
def exclaim(call_next, name):
    return call_next(name + "!")

def hello(name):
    print(f"Hello, {name}")

composed_hello = middleware.compose(hello)
>>> hello("sam")
Hello, sam
>>> composed_hello("sam")
Hello, SAM!

Metadata

Release files for mediate 0.1.8

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

Source distribution (sdist)

Source distribution for mediate 0.1.8
File Size Uploaded
mediate-0.1.8.tar.gz 3.5 kB Details

Built distribution (wheel)

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

Total release size: 8.2 kB

Release files / mediate-0.1.8.tar.gz

Download URL mediate-0.1.8.tar.gz
Size 3.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b92f618a89226281dea1e7115e5341fa3ecb9db6dd00772805fcb9d0ba214171
BLAKE2b-256 checksum
How to use checksums
3cda62b3cc202fad0be03380c852c207d9d6497778379341c224157abf0b3e79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.8.10 Linux/5.4.0-144-generic

Release files / mediate-0.1.8-py3-none-any.whl

Download URL mediate-0.1.8-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9863947fc0e98774bf57b10b6218f482cad8f1abc84618d7ca9e9760fcd31fab
BLAKE2b-256 checksum
How to use checksums
0bed63f72682ab3b2db30d83b45eea470bb0a90e4b06dd5e943cd1ae50b7e2a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.2 CPython/3.8.10 Linux/5.4.0-144-generic

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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