Midware
A simple general-purpose middleware library for Python 3.5 or greater.
Often the main task of a program can be represented as one function with rather straightforward input and output. But a lot of unrelated code needs to be added to make this one function doing one main task into an actual usable utility that, for example, handles user input correctly.
One way to decomplect unrelated concerns in a program is a middleware pattern.
Middleware puts functions and composability first. To make it easier for functions with different signatures to be composable all arguments are usually packed into one dictionary called ctx for “context”. All functions take ctx as an argument, modify it and return it.
Functions that modify the ctx are called handlers. Handlers are already very composable by design and one can easily pipe ctx values through a series of handlers, but that’s often not enough. One of the most frequently used patterns (a lot of languages even have built-in keywords for it, Python has several actually) is the “setup-teardown” pattern. That is where middleware comes in.
Middleware is a higher-order function that takes a handle and return a new handle, which typically wraps the old one. It does some work, maybe modifies the ctx, passes it to the old handle, gets a new ctx back and optionally does something else before returning.
Once again, middleware is composable, because it takes handles and returns handles. When using middleware as building blocks, composing those returns an outermost handle, which needs to be called with a ctx value as an argument to kick off the computation.
Metadata
Release files for midware 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| midware-0.5.1.tar.gz | 4.7 kB | Without provenance | Details for midware-0.5.1.tar.gz |
Release files / midware-0.5.1.tar.gz
| Download URL | midware-0.5.1.tar.gz |
|---|---|
| Size | 4.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5a088cffe5a05f6ac1c80dbba05bcfdbb554ed13a12c3da32121471482357020
|
|
BLAKE2b-256 checksum How to use checksums |
7f7fe27bde9e077a29cca16573b178b3642915e563431306c2333facdc0f3af2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for midware 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.