macro_rules! services { ($($x:expr),+ $(,)?) => { ... }; }
Expand description
Macro to help register different types of services at the same time.
The max number of services that can be grouped together is 12 and all must implement the
HttpServiceFactory
trait.
ยงExamples
use actix_web::{services, web, App};
let services = services![
web::resource("/test2").to(|| async { "test2" }),
web::scope("/test3").route("/", web::get().to(|| async { "test3" }))
];
let app = App::new().service(services);
// services macro just convert multiple services to a tuple.
// below would also work without importing the macro.
let app = App::new().service((
web::resource("/test2").to(|| async { "test2" }),
web::scope("/test3").route("/", web::get().to(|| async { "test3" }))
));