#[prologue_hooks]Expand description
Executes multiple specified functions before the main handler function.
This attribute macro configures multiple pre-execution hooks that run before the main function logic. The specified hook functions will be called in the order provided, followed by the main function execution.
ยงUsage
use hyperlane::*;
use hyperlane_macros::*;
struct PrologueHooks;
impl ServerHook for PrologueHooks {
async fn new(_ctx: &Context) -> Self {
Self
}
#[get]
#[http]
async fn handle(self, _ctx: &Context) {}
}
async fn prologue_hooks_fn(ctx: Context) {
let hook = PrologueHooks::new(&ctx).await;
hook.handle(&ctx).await;
}
#[route("/hook")]
struct Hook;
impl ServerHook for Hook {
async fn new(_ctx: &Context) -> Self {
Self
}
#[prologue_hooks(prologue_hooks_fn)]
#[response_body("Testing hook macro")]
async fn handle(self, ctx: &Context) {}
}The macro accepts a comma-separated list of function names as parameters. All hook functions
and the main function must accept a Context parameter. Avoid combining this macro with other
macros on the same function to prevent macro expansion conflicts.