Attribute Macro actix_web::routes

source ·
#[routes]
Available on crate feature macros only.
Expand description

Creates resource handler, allowing multiple HTTP methods and paths.

§Syntax

#[routes]
#[<method>("path", ...)]
#[<method>("path", ...)]
...

§Attributes

The routes macro itself has no parameters, but allows specifying the attribute macros for the multiple paths and/or methods, e.g. GET and POST.

These helper attributes take the same parameters as the single method handlers.

§Examples

#[routes]
#[get("/test")]
#[get("/test2")]
#[delete("/test")]
async fn example() -> HttpResponse {
    HttpResponse::Ok().finish()
}