hyperlane 20.0.1

A lightweight, high-performance, and cross-platform Rust HTTP server library built on Tokio. It simplifies modern web service development by providing built-in support for middleware, WebSocket, Server-Sent Events (SSE), and raw TCP communication. With a unified and ergonomic API across Windows, Linux, and MacOS, it enables developers to build robust, scalable, and event-driven network applications with minimal overhead and maximum flexibility.
Documentation
use crate::*;

/// Represents different types of hooks in the server lifecycle.
///
/// Each variant corresponds to a specific hook that can be registered
/// and triggered at different stages of request handling or server events.
/// Hooks with an `Option<isize>` allow specifying a priority order; `None` indicates
/// the default order (0 or unspecified).
#[derive(Clone, Copy, Debug, DisplayDebug)]
pub enum HookType {
    /// Hook triggered when a task panic occurs during request processing.
    ///
    /// - `Option<isize>` - Optional execution priority. Higher values execute first.
    /// - `ServerHookHandlerFactory` - Factory function creating the panic handler.
    TaskPanic(Option<isize>, ServerHookHandlerFactory),
    /// Hook triggered when a request error occurs during HTTP request processing.
    ///
    /// - `Option<isize>` - Optional execution priority. Higher values execute first.
    /// - `ServerHookHandlerFactory` - Factory function creating the error handler.
    RequestError(Option<isize>, ServerHookHandlerFactory),
    /// Hook executed before a request reaches its designated route handler.
    ///
    /// - `Option<isize>` - Optional execution priority. Higher values execute first.
    /// - `ServerHookHandlerFactory` - Factory function creating the middleware handler.
    RequestMiddleware(Option<isize>, ServerHookHandlerFactory),
    /// Hook representing a route handler for a specific path.
    ///
    /// - `&'static str` - The route path pattern handled by this hook.
    /// - `ServerHookHandlerFactory` - Factory function creating the route handler.
    Route(&'static str, ServerHookHandlerFactory),
    /// Hook executed after a route handler but before the response is sent.
    ///
    /// - `Option<isize>` - Optional execution priority. Higher values execute first.
    /// - `ServerHookHandlerFactory` - Factory function creating the middleware handler.
    ResponseMiddleware(Option<isize>, ServerHookHandlerFactory),
}