A generic functional middleware infrastructure for Python.
Project description
Formation
A generic functional middleware infrastructure for Python.
Take a look:
from datetime.datetime import now
from formation import wrap
from requests import get
def log(ctx, call):
print("started")
ctx = call(ctx)
print("ended")
return ctx
def timeit(ctx, call):
started = now()
ctx = call(ctx)
ended = now() - started
ctx['duration'] = ended
return ctx
def to_requests(ctx):
get(ctx['url'])
fancy_get = wrap(to_requests, middleware=[log, timeit])
fancy_get({'url':'https://google.com'})
Quick Start
Install using pip/pipenv/etc. (we recommend poetry for sane dependency management):
$ poetry add formation
Thanks:
To all Contributors - you make this happen, thanks!
Copyright
Copyright (c) 2018 @jondot. See LICENSE for further details.
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
formation-0.1.10.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for formation-0.1.10-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32f977507b6577ffc3ab2dec778c6fd68c99dc4942d24cf66b29ea042ee86b5c |
|
MD5 | 2b54076261dea94f7081af855d98705f |
|
BLAKE2b-256 | c5dceb7bf4d1cca3cb7c66163fda5cc5b6c9dd32f399f4b55d2e442914bd5c73 |