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(_: &mut Stream, _: &mut Context) -> Self {
        Self
    }

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

impl Patch {
    #[patch_method]
    async fn patch_with_ref_self(&self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}

#[patch_method]
async fn standalone_patch_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.