protorig
A small Python web framework with a Rust core, supporting both ASGI and RSGI. It takes inspiration from most of the established web frameworks including sanic and FastAPI
Features
- async only
- ASGI and RSGI compatible — run it under uvicorn, granian, or any compliant server
- radix-tree router in rust based on go's httprouter
- Function-based routing with decorators
- Dependency injection via
Depends - Helpers for text, JSON, file, and redirect responses
- Customisable exception handlers
- Composable route groups with prefixes and mounting
Requirements
- Python 3.13+
- orjson
- anyio
- msgspec
- A Rust toolchain (only needed to build from source)
Installation
Pre-built wheels are published on PyPI, install with your preferred package manager:
pip install protorig
Building from source
protorig is built with maturin. To build and install from a checkout:
uv sync
uv run maturin develop
This compiles the Rust core (protorig.core) and installs the package into your environment.
Quick start
import uvicorn
from typing import Annotated
from protorig import responses
from protorig.application import Application
from protorig.depends import Depends
from protorig.routes import Routes
routes = Routes()
def get_db():
return "clearly a database"
@routes.get("/user/:id")
async def get_user(id: int, db: Annotated[str, Depends(get_db)]):
return responses.text(f"user({db}) -- {id}", 200)
app = Application(routes)
if __name__ == "__main__":
uvicorn.run(app, host="0.0.0.0", port=8000)
Routing
Create a Routes group and register handlers with the per-method decorators
(get, post, put, delete, patch, options, head) or the generic
route decorator:
routes = Routes()
@routes.get("/health")
async def health():
return responses.text("ok")
@routes.route(["GET", "POST"], "/echo")
async def echo(request: Request):
return responses.json(await request.json())
Path parameters
Path segments prefixed with : are captured and passed to the handler by name.
Annotate the parameter to have its value coerced to that type:
@routes.get("/post/:slug/comment/:id")
async def comment(slug: str, id: int):
...
Prefixes and mounting
A Routes group can be given a prefix, and groups can be composed by mounting
one into another — either directly or by import path:
api = Routes(prefix="/api")
root = Routes()
root.mount(api)
root.mount("myapp.users:routes", prefix="/v1")
Dependency injection
Declare dependencies with Depends. They are resolved per request, and the
resolved value is injected into your handler:
from typing import Annotated
from protorig.depends import Depends
def get_db():
return "db"
@routes.get("/items")
async def list_items(db: Annotated[str, Depends(get_db)]):
...
The current Request can be injected by annotating a parameter with the
Request type.
Responses
The protorig.responses module provides helpers that return an HTTPResponse:
| Helper | Purpose |
|---|---|
responses.text(body, status=200, ...) |
Plain-text response |
responses.json(body, status=200, ...) |
JSON response (serialised with orjson) |
responses.file(path, ...) |
File response with caching / conditional headers |
responses.redirect(url, status=302, ...) |
Redirect response |
Exception handling
Register handlers for specific exception types with
Application.exception_handler. HTTPException is handled by default and
returns its detail and status_code:
from protorig.exceptions import HTTPException
@app.exception_handler(HTTPException)
async def handle_http(request, exception: HTTPException):
return responses.text(exception.detail, exception.status_code)
Unhandled exceptions are logged and produce a 500 Internal Server Error.
License
BSD-3-Clause
Metadata
Release files for protorig 0.2.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 |
|---|---|---|---|---|
| protorig-0.2.1.tar.gz | 36.7 kB | Without provenance | Details for protorig-0.2.1.tar.gz |
Built distributions (wheels)
Total release size: 2.4 MB
Release files / protorig-0.2.1.tar.gz
| Download URL | protorig-0.2.1.tar.gz |
|---|---|
| Size | 36.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7514c01cef4fbf315b6aa3d75b082505cf7ff878ca601bf7ef86274e0115075d
|
|
BLAKE2b-256 checksum How to use checksums |
22ccc2c11d1a900aa02336745881c49c7fcd5969e860bd9434b6dc6fe19032a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / protorig-0.2.1-cp314-cp314-win_amd64.whl
| Download URL | protorig-0.2.1-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 265.6 kB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
01168912fbc8f407507d76e53dde44eb536c54f7404fb038101bc98cc6ff1a3e
|
|
BLAKE2b-256 checksum How to use checksums |
c74d7da9583ff9886b7f6ae01a68403e8141294fdb17cb534e94d9c8db614805
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / protorig-0.2.1-cp314-cp314-musllinux_1_2_x86_64.whl
| Download URL | protorig-0.2.1-cp314-cp314-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 493.0 kB |
| Tags | CPython 3.14 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
65048db84afecf024e3753b9182c56f14ebadbf3b08953fad7a0e6b2a027baac
|
|
BLAKE2b-256 checksum How to use checksums |
2ec4fafe7d6b937e940701b948b2974d2f6d2680e0058dbd3e9e2d38d9ff282e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.24.0_alpha20260127","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / protorig-0.2.1-cp314-cp314-manylinux_2_34_x86_64.whl
| Download URL | protorig-0.2.1-cp314-cp314-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 417.1 kB |
| Tags | CPython 3.14 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
dd6d601d8f5df734b05b4e9437899c4cf72ee5b7659b63c5c0b25ba8971ceaaa
|
|
BLAKE2b-256 checksum How to use checksums |
3795b23acf8b6e14d31637b48155e4ede631ab19b78e83118f5ec8eb7fe49ded
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / protorig-0.2.1-cp313-cp313-win_amd64.whl
| Download URL | protorig-0.2.1-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 265.3 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
6455feb18fd82671f69b907621e3367d9d9552330739ade43cb4cb5979369bc2
|
|
BLAKE2b-256 checksum How to use checksums |
cc5cd3f1b5892e96e5f4921112d9e01c37c587d11094c830993a892c4940f178
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / protorig-0.2.1-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | protorig-0.2.1-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 492.8 kB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
a0ed63a8d350e018a09072fe48cd85204c522da4f99b3f39eeb7a609a5e97219
|
|
BLAKE2b-256 checksum How to use checksums |
690a92f5a23f64434b4f6829edabb8035574c2f0547cf856f6968b88088d57a2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Alpine Linux","version":"3.24.0_alpha20260127","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / protorig-0.2.1-cp313-cp313-manylinux_2_34_x86_64.whl
| Download URL | protorig-0.2.1-cp313-cp313-manylinux_2_34_x86_64.whl |
|---|---|
| Size | 417.0 kB |
| Tags | CPython 3.13 Linux glibc 2.34+ x86-64 |
|
SHA-256 checksum How to use checksums |
c72883ca803bbaff183e9e6f3380a7c45dafc889d75da8078e7dc6453d66bcb1
|
|
BLAKE2b-256 checksum How to use checksums |
2cbb2992830fafb3316b63075ce2d862ffa7764ae15205c6ef56972e4e91e899
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for protorig 0.2.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.