Skip to main content

Lightweight router for building HTTP services.

Project description

muxy

muxy is a lightweight router for building HTTP services conforming to Granian's Rust Server Gateway Interface (RSGI). It intentionally avoids magic, prioritising explicit and composable code.

uv add muxy

Features

  • first-class router composition - modularise your code by nesting routers with no overhead
  • correct, efficient routing - explicit route heirarchy so behaviour is always predictable
  • lightweight - the core router is little more than a simple datastructure and has no dependencies
  • control - control the full HTTP request/response cycle without digging through framework layers
  • middleware - apply common logic to path groups simply and clearly

Inspiration

Go's net/http and go-chi/chi are inspirations for muxy. I wanted their simplicity without having to switch language. You can think of the RSGI interface as the muxy equivalent of the net/http HandlerFunc interface, and muxy.Router as an equivalent of chi's Mux.

Examples

Getting started

import asyncio

from granian.server.embed import Server
from muxy.router import Router
from muxy.rsgi import HTTPProtocol, HTTPScope

async def home(s: HTTPScope, p: HTTPProtocol) -> None:
    p.response_str(200, [], "Hello world!")

async def main() -> None:
    router = Router()
    router.get("/", home)

    server = Server(router)
    await server.serve()

if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

muxy-0.1.0.dev9.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

muxy-0.1.0.dev9-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file muxy-0.1.0.dev9.tar.gz.

File metadata

  • Download URL: muxy-0.1.0.dev9.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for muxy-0.1.0.dev9.tar.gz
Algorithm Hash digest
SHA256 3dcb5d89b1deda90f5f5737bba29220a8d76aa1b3b32a81cd06a0dc4561139e2
MD5 69482ab5f4f185534c1dc0940f25e046
BLAKE2b-256 4df9a5d7b7fbbc98f97a8bc0fb1abbb1e2cf582e4f515acfddef3aeb04826c2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for muxy-0.1.0.dev9.tar.gz:

Publisher: release.yaml on oliverlambson/muxy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file muxy-0.1.0.dev9-py3-none-any.whl.

File metadata

  • Download URL: muxy-0.1.0.dev9-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for muxy-0.1.0.dev9-py3-none-any.whl
Algorithm Hash digest
SHA256 96da6651a6b4503609ef665f27a6e1b08386e6bf63a07376d656b4db8fcc7386
MD5 d5996a24d29a36cd960f89ce81da43ea
BLAKE2b-256 d1e45c4d84387c3776c0b3850f9dfe24860773a5666346d8d0f63308da175fe2

See more details on using hashes here.

Provenance

The following attestation bundles were made for muxy-0.1.0.dev9-py3-none-any.whl:

Publisher: release.yaml on oliverlambson/muxy

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page