#routing #axum #distributed #risk #string

macro axum-distributed-routing-macros

Distributed routing macros for axum

4 releases

Uses new Rust 2024

0.1.3 Apr 2, 2025
0.1.2 Apr 2, 2025
0.1.1 Apr 2, 2025
0.1.0 Apr 2, 2025

#2936 in Procedural macros

Download history 293/week @ 2025-03-29 83/week @ 2025-04-05 2/week @ 2025-04-12 2/week @ 2025-04-19

380 downloads per month
Used in axum-distributed-routing

MIT license

17KB
329 lines

Axum Distributed Routing

[!WARNING] This crate is experimental, use at your own risk!

Provides utilities for generating statically typed distributed routes for axum.

Usage

use axum_distributed_routing::*;

struct MyState(String);

route_group!(MyRoutes, MyState);

route!(
    group = MyRoutes,
    path = "/hello/{name:String}",
    method = GET,
    async hello -> String {
        format!("{} {}!", state.0, name)
    }
);

#[tokio::main]
async fn main() {
    let app = create_router!(MyRoutes);

    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await.unwrap();

    axum::serve(listener, app).await.unwrap();
}

Dependencies

~0.7–1.2MB
~29K SLoC