2019-06-30 16:45:17 +00:00
|
|
|
use futures::future::Future;
|
|
|
|
|
2019-06-13 01:48:02 +00:00
|
|
|
use crate::{Request, Data};
|
|
|
|
use crate::handler::{Outcome, ErrorHandler};
|
|
|
|
use crate::http::{Method, MediaType};
|
2016-04-03 10:36:30 +00:00
|
|
|
|
2018-10-10 11:20:25 +00:00
|
|
|
/// Type of a static handler, which users annotate with Rocket's attribute.
|
2019-06-30 16:45:17 +00:00
|
|
|
pub type StaticHandler = for<'r> fn(&'r Request<'_>, Data) -> std::pin::Pin<Box<dyn Future<Output = Outcome<'r>> + Send + '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.
|
2016-04-06 10:26:43 +00:00
|
|
|
pub struct StaticCatchInfo {
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The catcher's status code.
|
2016-04-06 10:26:43 +00:00
|
|
|
pub code: u16,
|
2018-10-10 11:20:25 +00:00
|
|
|
/// The catcher's handler, i.e, the annotated function.
|
2016-09-30 22:20:11 +00:00
|
|
|
pub handler: ErrorHandler,
|
2016-04-06 10:26:43 +00:00
|
|
|
}
|