put

Attribute Macro put 

Source
#[put]
Expand description

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

§Parameters

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

§Usage

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

#[routes]
impl MyController {
    #[put("/item/{id}")]
    async fn update_item(&self, req: Request) -> HttpResult<HttpResponse> {
        Ok(HttpResponse::Ok().message("Item updated"))
    }
}