api_route

Attribute Macro api_route 

Source
#[api_route]
Expand description

Creates openapi resource handler.

§Syntax

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

§Attributes

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

§Examples

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