logo
macro_rules! services {
    ($($x:expr),+ $(,)?) => { ... };
}
Expand description

Macro helping register different types of services at the sametime.

The service type must be implementing HttpServiceFactory trait.

The max number of services can be grouped together is 12.

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" }))
));