Would like a help on code generation
⚓ Rust 📅 2025-12-10 👤 surdeus 👁️ 6I am working on the personal project so stuck between a problem
i want to generate route so i made some attribute macros i.e get,post etc.
for to simplify axum route registration but to register route we need function pointer to axum controller im not sure how to get it
- my basic idea was to make array of
#[derive(Debug, Clone, Copy)]
pub struct RouteMetaData {
pub method: &'static str,
pub path: &'static str,
pub handler_name: &'static str,
pub module: &'static str,
pub file: &'static str,
}
store them in linkme distributed slice but then hit the limit that i cant iterate our it without build script and build.rs runs before the generation main issue
so any solutions how can i make it work. Any work around or design pattern i should follow my end goal is get all route then register them why single file so that i can make something like this
let app = Router::new()
// `GET /` goes to `root`
.route("/", get(root))
// `POST /users` goes to `create_user`
.route("/users", post(create_user));
but using my macros or
i will need to right my own build.rs and then parser for everything im not sure yet
1 post - 1 participant
🏷️ Rust_feed