This release is a pre-release and may not be stable for production use.
Swarmauri Middleware JsonRpc
Middleware that performs simple validation of JSON-RPC requests.
Features
- Validates JSON request bodies for JSON-RPC payloads when the
Content-Typeheader starts withapplication/json. - Returns
400 Bad Requestwith a plain-text error when the body contains invalid JSON. - Ensures JSON object payloads define a
jsonrpcfield, responding with400 Bad Requestif it is missing.
Installation
Install the middleware with your preferred Python packaging workflow:
pip install swarmauri_middleware_jsonrpc
poetry add swarmauri_middleware_jsonrpc
uv add swarmauri_middleware_jsonrpc
uv pip install swarmauri_middleware_jsonrpc
Usage
from fastapi import FastAPI
from swarmauri_middleware_jsonrpc import JsonRpcMiddleware
app = FastAPI()
app.middleware("http")(JsonRpcMiddleware().dispatch)
The middleware integrates with FastAPI's app.middleware("http") hook and is
compatible with the MiddlewareBase ecosystem. Once registered, every incoming
JSON request is validated before reaching subsequent middleware or route
handlers.
Request Validation
- Requests without an
application/jsoncontent type bypass the middleware. - Malformed JSON bodies are rejected with a
400response containing the messageInvalid JSON. - JSON objects missing the
jsonrpckey are rejected with a400response and the messageMissing jsonrpc field.
Want to help?
If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.
Release files for swarmauri_middleware_jsonrpc 0.11.0.dev1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| swarmauri_middleware_jsonrpc-0.11.0.dev1.tar.gz | 7.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| swarmauri_middleware_jsonrpc-0.11.0.dev1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.0 kB
Release files / swarmauri_middleware_jsonrpc-0.11.0.dev1.tar.gz
| Download URL | swarmauri_middleware_jsonrpc-0.11.0.dev1.tar.gz |
|---|---|
| Size | 7.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e9977e9a82f40b75b43ec5b6d49e75ec82a733534b8698db204b49c4ffcfcd06
|
|
BLAKE2b-256 checksum How to use checksums |
0f63cd31df264e6f0334a527808d3a7e13b927b24fbcec8f505b68a925bd4e9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / swarmauri_middleware_jsonrpc-0.11.0.dev1-py3-none-any.whl
| Download URL | swarmauri_middleware_jsonrpc-0.11.0.dev1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
73e8c31d09aa9592fa7e72c16aceb48380048201514dd9de4739c6a49fba50b9
|
|
BLAKE2b-256 checksum How to use checksums |
6658ce0690aa27988cfa774776bfac9c7bde34937e282acbf9fb77176e5d0d91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|