mirror of https://github.com/rwf2/Rocket.git
35 lines
1.3 KiB
Rust
35 lines
1.3 KiB
Rust
use crate::{Request, Data};
|
|
use crate::handler::HandlerFuture;
|
|
use crate::catcher::ErrorHandlerFuture;
|
|
use crate::http::{Status, Method, MediaType};
|
|
|
|
/// Type of a route handler, generated from a `fn` annotated with `#[route]`.
|
|
pub type StaticHandler = for<'r> fn(&'r Request<'_>, Data) -> HandlerFuture<'r>;
|
|
|
|
/// Type of an error handler, generated from a `fn` annotated with `#[catch]`.
|
|
pub type StaticErrorHandler = for<'r> fn(Status, &'r Request<'_>) -> ErrorHandlerFuture<'r>;
|
|
|
|
/// Information generated by the `route` attribute during codegen.
|
|
pub struct StaticRouteInfo {
|
|
/// The route's name, i.e, the name of the function.
|
|
pub name: &'static str,
|
|
/// The route's method.
|
|
pub method: Method,
|
|
/// The route's path, without the base mount point.
|
|
pub path: &'static str,
|
|
/// The route's format, if any.
|
|
pub format: Option<MediaType>,
|
|
/// The route's handler, i.e, the annotated function.
|
|
pub handler: StaticHandler,
|
|
/// The route's rank, if any.
|
|
pub rank: Option<isize>,
|
|
}
|
|
|
|
/// Information generated by the `catch` attribute during codegen.
|
|
pub struct StaticCatcherInfo {
|
|
/// The catcher's status code.
|
|
pub code: Option<u16>,
|
|
/// The catcher's handler, i.e, the annotated function.
|
|
pub handler: StaticErrorHandler,
|
|
}
|