fire_http/routes/
raw_route.rs

1use std::net::SocketAddr;
2
3use crate::util::PinnedFuture;
4use crate::{Resources, Response};
5
6pub use crate::server::{HyperBody, HyperRequest};
7
8use super::{ParamsNames, PathParams, RoutePath};
9
10/// A `RawRoute` is the more powerfull brother/sister to `Route`. It get's
11/// executed before `Route`.
12/// The `RawRoute` should only be needed if you implement something lower level
13/// like websockets and need access to the underlying hyper types.
14pub trait RawRoute: Send + Sync {
15	// check if every data you expect is in Data
16	fn validate_requirements(&self, _params: &ParamsNames, _data: &Resources) {}
17
18	// get's only called once
19	fn path(&self) -> RoutePath;
20
21	fn call<'a>(
22		&'a self,
23		req: &'a mut HyperRequest,
24		address: SocketAddr,
25		params: &'a PathParams,
26		resources: &'a Resources,
27	) -> PinnedFuture<'a, Option<crate::Result<Response>>>;
28}