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
orUri
. (Anything that implementsToString
) Anything accepted bymount()
- openapi_settings:
OpenApiSettings
(useOpenApiSettings::default()
if default settings are okay for you), - List of (0 or more):
- path:
&str
,String
orUri
. Anything accepted bymount()
(base_path
should not be included). =>
: divider- route_and_docs:
(Vec<rocket::Route>, OpenApi)
- path:
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(),
};