Attribute Macro route

Source
#[route]
Expand description

Creates resource handler, allowing multiple HTTP method guards.

§Syntax

#[route("path", method="HTTP_METHOD"[, attributes])]

§Attributes

  • "path": Raw literal string with path for which to register handler.
  • method = "HTTP_METHOD": Registers HTTP method to provide guard for. Upper-case string, “GET”, “POST” for example.

§Examples

#[route("/test", method = "GET", method = "HEAD")]
async fn example() -> impl IntoResponse {
    "hello world"
}