Skip to main content

put_method

Attribute Macro put_method 

Source
#[put_method]
Expand description

Restricts function execution to HTTP PUT requests only.

This attribute macro ensures the decorated function only executes when the incoming request uses the PUT HTTP method. Requests with other methods will be filtered out.

ยงUsage

use hyperlane::*;
use hyperlane_macros::*;

#[route("/put_method")]
struct Put;

impl ServerHook for Put {
    async fn new(_ctx: &mut Context) -> Self {
        Self
    }

    #[prologue_macros(put_method, response_body("put_method"))]
    async fn handle(self, ctx: &mut Context) {}
}

impl Put {
    #[put_method]
    async fn put_with_ref_self(&self, ctx: &mut Context) {}
}

#[put_method]
async fn standalone_put_handler(ctx: &mut Context) {}

The macro takes no parameters and should be applied directly to async functions that accept a &mut Context parameter.