erest
    Preparing search index...

    Interface LifecycleHooks

    生命周期 hook 集合(同步观察者,不参与控制流)

    interface LifecycleHooks {
        onError?: (ctx: Context, error: Error | ERestError) => void;
        onRequest?: (ctx: Context) => void;
        onResponse?: (ctx: Context) => void;
        onValidate?: (ctx: Context, result: Error | LayeredParams) => void;
    }
    Index

    Properties

    onError?: (ctx: Context, error: Error | ERestError) => void

    链中抛错时:结构化错误日志(保留 ERestError code/details)

    onRequest?: (ctx: Context) => void

    进入中间件链最开始:注入 traceId、开始计时、访问日志

    onResponse?: (ctx: Context) => void

    链正常结束、响应已写入:结束计时、状态码、慢请求标记

    onValidate?: (ctx: Context, result: Error | LayeredParams) => void

    参数校验完成后:记录校验耗时、失败字段