get

Attribute Macro get 

Source
#[get]
Expand description

Defines a handler for HTTP GET requests. This macro should be used inside an impl block of a struct annotated with the #[controller] macro.

§Parameters

  • path: The path for the GET request, e.g., "/items"

§Usage

#[controller("/api")]
struct MyController {}

#[routes]
impl MyController {
    #[get("/items")]
    async fn get_items(&self) -> HttpResponse {
        HttpResponse::Ok().message("List of items")
    }
}