Skip to main content

alux_http_rocket/
message.rs

1//! What Rocket routed to an endpoint, before the roles read it.
2
3use rocket::http::HeaderMap;
4
5/// What one matched request states, as Rocket routed it.
6#[derive(Debug, Clone)]
7pub struct RocketRequest {
8    pub(crate) captures: Vec<String>,
9    pub(crate) query: String,
10    pub(crate) headers: HeaderMap<'static>,
11    pub(crate) body: Vec<u8>,
12}
13
14impl RocketRequest {
15    /// Returns what the path bound, in the order the path binds it.
16    pub fn captures(&self) -> &[String] {
17        &self.captures
18    }
19
20    /// Returns the query string this request carries.
21    pub fn query(&self) -> &str {
22        &self.query
23    }
24
25    /// Returns the headers this request carries.
26    pub fn headers(&self) -> &HeaderMap<'static> {
27        &self.headers
28    }
29
30    /// Returns the body this request carries.
31    pub fn body(&self) -> &[u8] {
32        &self.body
33    }
34}