chemin

Crates.iochemin
lib.rschemin
version0.1.0
sourcesrc
created_at2022-12-11 14:00:58.829874
updated_at2022-12-11 14:00:58.829874
descriptionAn enum-based router generator, supporting query strings and i18n.
homepage
repositoryhttps://github.com/Mahdrentys/chemin-rs
max_upload_size
id734353
size32,603
Mahdrentys (Mahdrentys)

documentation

README

Chemin

An enum-based router generator for rust, supporting query strings and i18n. It can be used on front-end or back-end, with any framework or library. It can be used both ways: to parse a url into a route, and to generate a url from a route you constructed.

It is not meant to be "blazingly fast": in this crate, code clarity is always privileged over optimization.

Example

See the API documentation for more detailed explanations.

#[derive(Chemin)]
enum Route {
    #[route("/")]
    Home,

    #[route(en => "/about")]
    #[route(fr => "/a-propos")]
    About,

    #[route(en => "/hello/:name")]
    #[route(fr => "/bonjour/:name")]
    Hello {
        name: String,
        #[query_param(optional)]
        age: Option<u8>,
    },

    #[route("/sub-route/..")]
    SubRoute(SubRoute),
}

#[derive(Chemin)]
enum SubRoute {
    #[route("/a")]
    A,

    #[route("/b")]
    B,
}
Commit count: 0

cargo fmt