Skip to main content

options_method

Attribute Macro options_method 

Source
#[options_method]
Expand description

Restricts function execution to HTTP OPTIONS requests only.

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

ยงUsage

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

#[route("/options_method")]
struct Options;

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

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

impl Options {
    #[options_method]
    async fn options_with_ref_self(&self, ctx: &mut Context) {}
}

#[options_method]
async fn standalone_options_handler(ctx: &mut Context) {}

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