maw

Crates.iomaw
lib.rsmaw
version0.18.1
created_at2025-11-02 06:17:47.166388+00
updated_at2026-01-23 16:20:29.490133+00
descriptionA simple and efficient web framework for Rust.
homepage
repositoryhttps://github.com/Srlion/maw
max_upload_size
id1912718
size141,463
(Srlion)

documentation

README

Maw

A minimal, fast web framework for Rust built on Hyper.

Features

  • Simple routing with path parameters
  • Middleware support (global and local)
  • Template rendering with MiniJinja
  • Request/response helpers for JSON, forms, and XML
  • Type-safe locals for sharing data
  • Graceful shutdown built-in

Quick Start

use maw::prelude::*;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut app = App::new();

    let router = Router::new().get("/", async |c: &mut Ctx| {
        c.res.send("Hello, world!");
        Ok(())
    });

    // to have it with middlewares, can be done like this:
    let router = Router::new()
        .middleware(async |c: &mut Ctx| {
            c.next().await;
        })
        .get("/", async |c: &mut Ctx| {
            c.res.send("Hello, world!");
            Ok(())
        });

    // or
    let router = Router::new().get(
        "/",
        (
            async |c: &mut Ctx| {
                c.next().await;
            },
            async |c: &mut Ctx| {
                c.res.send("Hello, world!");
                Ok(())
            },
        ),
    );

    app.router(router).listen("127.0.0.1:3000").await?;
    Ok(())
}

License

MIT

Commit count: 108

cargo fmt