[][src]Attribute Macro saphir_macro::controller

#[controller]

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

This example is not tested
#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 basepath
  • prefix="<prefix>" add a prefix before the basepath and the version.

##Example

This example is not tested
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