dynami 0.1.0

Automatic Axum router generation from directory structure with file-system based routing
Documentation
pub fn parse_route_segment(folder_name: &str) -> String {
    // Handle wildcard dynamic routes: d_*rest -> /{*rest}
    if folder_name.starts_with("d_*") {
        format!("/{{*{}}}", &folder_name[3..])
    }
    // Handle regular dynamic routes: d_id -> /{id}
    else if folder_name.starts_with("d_") {
        format!("/{{{}}}", &folder_name[2..])
    }
    // Static routes
    else {
        format!("/{}", folder_name)
    }
}

pub fn extract_method_from_filename(filename: &str) -> Option<&str> {
    match filename {
        "get.rs" => Some("get"),
        "post.rs" => Some("post"),
        "put.rs" => Some("put"),
        "delete.rs" => Some("delete"),
        "patch.rs" => Some("patch"),
        "options.rs" => Some("options"),
        "head.rs" => Some("head"),
        _ => None,
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_parse_static_route() {
        assert_eq!(parse_route_segment("api"), "/api");
        assert_eq!(parse_route_segment("users"), "/users");
    }

    #[test]
    fn test_parse_dynamic_route() {
        assert_eq!(parse_route_segment("d_id"), "/{id}");
        assert_eq!(parse_route_segment("d_user_id"), "/{user_id}");
    }

    #[test]
    fn test_parse_wildcard_route() {
        assert_eq!(parse_route_segment("d_*rest"), "/{*rest}");
        assert_eq!(parse_route_segment("d_*path"), "/{*path}");
    }

    #[test]
    fn test_extract_method() {
        assert_eq!(extract_method_from_filename("get.rs"), Some("get"));
        assert_eq!(extract_method_from_filename("post.rs"), Some("post"));
        assert_eq!(extract_method_from_filename("other.rs"), None);
    }
}