hyperlane/hook/enum.rs
1use crate::*;
2
3/// Represents different types of hooks in the server lifecycle.
4///
5/// Each variant corresponds to a specific hook that can be registered
6/// and triggered at different stages of request handling or server events.
7/// Hooks with an `Option<isize>` allow specifying a priority order; `None` indicates
8/// the default order (0 or unspecified).
9#[derive(Clone, Copy, Debug, DisplayDebug)]
10pub enum HookType {
11 /// Hook triggered when a task panic occurs during request processing.
12 ///
13 /// - `Option<isize>` - Optional execution priority. Higher values execute first.
14 /// - `ServerHookHandlerFactory` - Factory function creating the panic handler.
15 TaskPanic(Option<isize>, ServerHookHandlerFactory),
16 /// Hook triggered when a request error occurs during HTTP request processing.
17 ///
18 /// - `Option<isize>` - Optional execution priority. Higher values execute first.
19 /// - `ServerHookHandlerFactory` - Factory function creating the error handler.
20 RequestError(Option<isize>, ServerHookHandlerFactory),
21 /// Hook executed before a request reaches its designated route handler.
22 ///
23 /// - `Option<isize>` - Optional execution priority. Higher values execute first.
24 /// - `ServerHookHandlerFactory` - Factory function creating the middleware handler.
25 RequestMiddleware(Option<isize>, ServerHookHandlerFactory),
26 /// Hook representing a route handler for a specific path.
27 ///
28 /// - `&'static str` - The route path pattern handled by this hook.
29 /// - `ServerHookHandlerFactory` - Factory function creating the route handler.
30 Route(&'static str, ServerHookHandlerFactory),
31 /// Hook executed after a route handler but before the response is sent.
32 ///
33 /// - `Option<isize>` - Optional execution priority. Higher values execute first.
34 /// - `ServerHookHandlerFactory` - Factory function creating the middleware handler.
35 ResponseMiddleware(Option<isize>, ServerHookHandlerFactory),
36}