Skip to main content

send_body

Attribute Macro send_body 

Source
#[send_body]
Expand description

Automatically sends only the response body after function execution.

This attribute macro ensures that only the response body is automatically sent to the client after the function completes, handling request headers separately.

§Usage

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

#[route("/send_body")]
struct SendBodyTest;

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

    #[epilogue_macros(send_body)]
    async fn handle(self, ctx: &mut Context) {}
}

impl SendBodyTest {
    #[send_body]
    async fn send_body_with_ref_self(&self, ctx: &mut Context) {}
}

#[send_body]
async fn standalone_send_body_handler(ctx: &mut Context) {}

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

§Panics

This macro will panic if the send body operation fails.