2019-06-13 01:48:02 +00:00
|
|
|
use crate::{Request, Data};
|
2020-07-30 06:07:22 +00:00
|
|
|
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>;
|
2016-04-03 10:36:30 +00:00
|
|
|
|
2020-07-30 06:07:22 +00:00
|
|
|
/// Type of an error handler, generated from a `fn` annotated with `#[catch]`.
|
|
|
|
pub type StaticErrorHandler = for<'r> fn(Status, &'r Request<'_>) -> ErrorHandlerFuture<'r>;
|
2017-09-28 21:22:03 +00:00
|
|
|
|
2018-10-10 11:20:25 +00:00
|
|
|
/// Information generated by the `route` attribute during codegen.
|
2016-04-03 10:36:30 +00:00
|
|
|
pub struct StaticRouteInfo {
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The route's name, i.e, the name of the function.
|
2017-08-19 01:37:25 +00:00
|
|
|
pub name: &'static str,
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The route's method.
|
2016-04-03 10:36:30 +00:00
|
|
|
pub method: Method,
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The route's path, without the base mount point.
|
2016-04-03 10:36:30 +00:00
|
|
|
pub path: &'static str,
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The route's format, if any.
|
2017-03-28 07:12:59 +00:00
|
|
|
pub format: Option<MediaType>,
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The route's handler, i.e, the annotated function.
|
2017-09-28 21:22:03 +00:00
|
|
|
pub handler: StaticHandler,
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The route's rank, if any.
|
2016-08-27 12:10:29 +00:00
|
|
|
pub rank: Option<isize>,
|
2016-04-03 10:36:30 +00:00
|
|
|
}
|
|
|
|
|
2018-10-10 11:20:25 +00:00
|
|
|
/// Information generated by the `catch` attribute during codegen.
|
2020-07-30 06:07:22 +00:00
|
|
|
pub struct StaticCatcherInfo {
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The catcher's status code.
|
2020-07-30 06:07:22 +00:00
|
|
|
pub code: Option<u16>,
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The catcher's handler, i.e, the annotated function.
|
2020-07-30 06:07:22 +00:00
|
|
|
pub handler: StaticErrorHandler,
|
2016-04-06 10:26:43 +00:00
|
|
|
}
|