#[post_method]Expand description
Restricts function execution to HTTP POST requests only.
This attribute macro ensures the decorated function only executes when the incoming request uses the POST HTTP method. Requests with other methods will be filtered out.
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
#[route("/post_method")]
struct Post;
impl ServerHook for Post {
async fn new(_: &mut Stream, _: &mut Context) -> Self {
Self
}
#[prologue_macros(post_method, response_body("post_method"))]
async fn handle(self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}
impl Post {
#[post_method]
async fn post_with_ref_self(&self, stream: &mut Stream, ctx: &mut Context) -> Status { Status::Continue }
}
#[post_method]
async fn standalone_post_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.