actix_web

Attribute Macro routes

source
#[routes]
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()
}