Skip to main content

patch_method

Attribute Macro patch_method 

Source
#[patch_method]
Expand description

Restricts function execution to HTTP PATCH requests only.

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

ยงUsage

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

#[route("/patch_method")]
struct Patch;

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

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

impl Patch {
    #[patch_method]
    async fn patch_with_ref_self(&self, ctx: &mut Context) {}
}

#[patch_method]
async fn standalone_patch_handler(ctx: &mut Context) {}

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