try_send_body_with_data

Attribute Macro try_send_body_with_data 

Source
#[try_send_body_with_data]
Expand description

Tries to send only the response body with data after function execution.

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

ยงUsage

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

#[route("/try_send_body_with_data")]
struct TrySendBodyWithData;

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

    #[epilogue_macros(try_send_body_with_data("Response body content"))]
    async fn handle(self, ctx: &Context) {}
}

The macro accepts data to send and should be applied to async functions that accept a &Context parameter.