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.6.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for formation-0.1.6-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5cc2eac5eaf0d3311ebf92435db885c256392f9ba588ebe29f9631b4e75c040 |
|
MD5 | cd337432a57dd55dc3c408e438ff7105 |
|
BLAKE2b-256 | f4d3b909b38dfb50ae07d514649a779b34268b81d13bac97768dd7c09a878c7a |