#[unknown_method]Expand description
Restricts function execution to unknown HTTP methods only.
This attribute macro ensures the decorated function only executes when the incoming request uses an HTTP method that is not one of the standard methods (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, CONNECT, TRACE). Requests with standard methods will be filtered out.
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/unknown_method")]
struct UnknownMethod;
impl ServerHook for UnknownMethod {
async fn new(_ctx: &Context) -> Self {
Self
}
#[prologue_macros(
clear_response_headers,
filter(ctx.get_request_is_unknown_method().await),
response_body("unknown_method")
)]
async fn handle(self, ctx: &Context) {}
}
impl UnknownMethod {
#[unknown_method]
async fn unknown_method_with_ref_self(&self, ctx: &Context) {}
}
#[unknown_method]
async fn standalone_unknown_method_handler(ctx: &Context) {}The macro takes no parameters and should be applied directly to async functions
that accept a &Context parameter.