Attribute Macro saphir_macro::controller
source · #[controller]
Expand description
Saphir macro for auto trait implementation on controllers
The base macro attribule look like this : #[controller]
and is to be put
on top of a Controller’s method impl block
ⓘ
#use saphir::prelude::*;
#use saphir_macro::controller;
#struct ExampleController;
#[controller]
impl ExampleController {
// ....
}
Different arguments can be passed to the controller macro:
name="<newName>"
will take place of the default controller name (by default the controller name is the struct name, lowercase, with the “controller keyword stripped”). the name will result as the basepath of the controller.version=<u16>
use for api version, the version will be added before the name as the controller basepathprefix="<prefix>"
add a prefix before the basepath and the version.
##Example
ⓘ
use saphir::prelude::*;
use saphir_macro::controller;
struct ExampleController;
#[controller(name="test", version=1, prefix="api")]
impl ExampleController {
// ....
}
This will result in the Example controller being routed to /api/v1/test