Middleware for every occasion
Project description
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!
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
mediate-0.1.8.tar.gz
(3.5 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 mediate-0.1.8.tar.gz.
File metadata
- Download URL: mediate-0.1.8.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.10 Linux/5.4.0-144-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b92f618a89226281dea1e7115e5341fa3ecb9db6dd00772805fcb9d0ba214171
|
|
| MD5 |
1d7dcaefc31a4cd35a166df5a6f51ec4
|
|
| BLAKE2b-256 |
3cda62b3cc202fad0be03380c852c207d9d6497778379341c224157abf0b3e79
|
File details
Details for the file mediate-0.1.8-py3-none-any.whl.
File metadata
- Download URL: mediate-0.1.8-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.2.2 CPython/3.8.10 Linux/5.4.0-144-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9863947fc0e98774bf57b10b6218f482cad8f1abc84618d7ca9e9760fcd31fab
|
|
| MD5 |
1991dc18d33457287b9dbc383dc90e3d
|
|
| BLAKE2b-256 |
0bed63f72682ab3b2db30d83b45eea470bb0a90e4b06dd5e943cd1ae50b7e2a5
|