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.7.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for formation-0.1.7-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 040a294d66a0144783789ef44d958e2b59f0431d260601297094927b127b7efb |
|
MD5 | 0c82fb44d0c2a6118dc4706198db04ef |
|
BLAKE2b-256 | 60a38a7022921db99a73c45a301e3985a0b35945b65976c6d5e67ea6fd79d1b0 |