Skip to main content

delete_method

Attribute Macro delete_method 

Source
#[delete_method]
Expand description

Restricts function execution to HTTP DELETE requests only.

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

ยงUsage

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

#[route("/delete_method")]
struct Delete;

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

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

impl Delete {
    #[delete_method]
    async fn delete_with_ref_self(&self, ctx: &mut Context) {}
}

#[delete_method]
async fn standalone_delete_handler(ctx: &mut Context) {}

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