Crates.io | chemin |
lib.rs | chemin |
version | 0.1.0 |
source | src |
created_at | 2022-12-11 14:00:58.829874 |
updated_at | 2022-12-11 14:00:58.829874 |
description | An enum-based router generator, supporting query strings and i18n. |
homepage | |
repository | https://github.com/Mahdrentys/chemin-rs |
max_upload_size | |
id | 734353 |
size | 32,603 |
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.
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,
}