A FastAPI middleware to handle the GNU Headers (Memorial Headers) of the Clacks (Going Postal Terry Pratchett) for 'sending people home'.
Project description
Clacks GNU middleware
Lightweight FastAPI/Starlette middleware that keeps the tradition alive by adding the X-Clacks-Overhead HTTP header. Incoming headers are preserved, defaults can be configured, and duplicates are removed case-insensitively.
What it does
- Adds
X-Clacks-Overheadto every response, prefixed withGNUand joined by commas. - Merges incoming request names, your configured defaults, and any names already set on the response.
- Deduplicates names case-insensitively to avoid repeated entries.
- Simple configuration via a shared
clacks_configobject.
Install
pip install clacks-gnu-middleware
For local development:
pip install -e .
pip install -r requirements.txt # tooling & test extras
Quick start (FastAPI)
from fastapi import FastAPI
from clacks_gnu_middleware.clacks_middleware import clacks_middleware, clacks_config
app = FastAPI()
# Optional: customize defaults before registering the middleware
clacks_config.default_names.extend([
"Ada Lovelace",
"Alan Turing",
])
app.middleware("http")(clacks_middleware)
@app.get("/ping")
async def ping():
return {"status": "ok"}
# Run with: uvicorn app.application:app --reload
Header behavior
- Header name:
X-Clacks-Overhead. - Values are emitted as
GNU <name>, joined with commas. - Order: configured defaults → incoming header values → names already set on the response.
- Names are deduplicated (case-insensitive). Empty or non-
GNUvalues are ignored.
Testing
pytest
Notes
- The middleware uses a module-level
clacks_config; set defaults before registering the middleware to avoid runtime mutation. - License: GPL-3.0 (see LICENSE).
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
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 clacks_gnu_middleware-0.0.2.tar.gz.
File metadata
- Download URL: clacks_gnu_middleware-0.0.2.tar.gz
- Upload date:
- Size: 16.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8371df408e92687af76c744c4459fff5ad4cab3c367af43259abf4449df27955
|
|
| MD5 |
38145c53c0ebc7d726b245dc94c13735
|
|
| BLAKE2b-256 |
2d6071d217a5c5b52146cb18f10b41a92a156a5b378c71f5fccd6c3f6a8b1554
|
File details
Details for the file clacks_gnu_middleware-0.0.2-py3-none-any.whl.
File metadata
- Download URL: clacks_gnu_middleware-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e33b003c7e52d466d3a0c29a108646ce91fb7457ccf8bc03c5efa7f4d03689ea
|
|
| MD5 |
13ed690af8a440d79df3c31b87e56356
|
|
| BLAKE2b-256 |
84ac2afc8581ddfe9765cfd8701d04b04308584a60d71392910d49b37ffc6a81
|