Context:
Hello i'm kinda new to rust and currently reading The Book .
At the same time i'm trying to play a bit with the language.
I am trying to do stuff with the rocket framework (just basic todo api).
Question
I was wondering if it was possible to write a macro #[controller] that can take a whole module inside like so :
#[controller(base = "/route")]
mod TodoController {
#[get("/")]
fn some_stuff() -> &'static str {
return "yes"
}
}
This macro should do the same as this but without all the "Boilerplate" :
#[get("/")]
pub fn todo_index() -> &'static str {
"Todo Index"
}
inventory::submit! {
crate::inventory::modules::Module {
base: "/todo",
routes: || rocket::routes![
todo_index,
],
}
}
would that be something possible with the macros ?
PS: yes i'm trying to simulate the same kind of things as in NestJs