macro_rules! mount_endpoints_and_merged_docs {
    ($rocket_builder:ident, $base_path:expr, $openapi_settings:ident,
     $($path:expr => $route_and_docs:expr),* $(,)*) => { ... };
}
Expand description

Mount endpoints and mount merged OpenAPI documentation.

This marco just makes to code look cleaner and improves readability for bigger codebases.

The macro expects the following arguments:

  • rocket_builder: Rocket<Build>,
  • base_path: &str, String or Uri. (Anything that implements ToString) Anything accepted by mount()
  • openapi_settings: OpenApiSettings (use OpenApiSettings::default() if default settings are okay for you),
  • List of (0 or more):
    • path: &str, String or Uri. Anything accepted by mount() (base_path should not be included).
    • =>: divider
    • route_and_docs: (Vec<rocket::Route>, OpenApi)

Example:

let custom_route_spec = (vec![], custom_spec());
mount_endpoints_and_merged_docs! {
    building_rocket, "/v1".to_owned(),
    "/" => custom_route_spec,
    "/post" => post::get_routes_and_docs(),
    "/message" => message::get_routes_and_docs(),
};