Skip to main content

is_put_method

Attribute Macro is_put_method 

Source
#[is_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("/is_put_method")]
struct Put;

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

    #[prologue_macros(is_put_method, response_body("is_put_method"))]
    async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}

impl Put {
    #[is_put_method]
    async fn put_with_ref_self(&self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}

#[is_put_method]
async fn standalone_put_handler(stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }

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