[][src]Derive Macro rooty_derive::Routes

#[derive(Routes)]
{
    // Attributes available to this derive:
    #[route]
}

Use this proc-macro to auto-derive rooty::Routes for your route enum.

All the fields of your enum variants must implement Display and FromStr.

NOTE when Displayed, no fields should print any forward slashes '/'. This cannot be checked at compile-time. The route will panic in debug mode when you try to display it, in release mode it will just print but you will not be able to parse it again.

Example

use chrono::NaiveDate;

#[derive(Debug, Routes)]
pub enum MyRoutes {
    #[route = "/"]
    Home,
    #[route = "/about"]
    About,
    #[route = "/users/{id}"]
    User { id: i32 },
    #[route = "/posts/{date}"]
    Posts { date: NaiveDate },
    #[route = "/post/{title}"]
    Post { title: String },
}