Struct saphir::SyncRequest
source · pub struct SyncRequest { /* private fields */ }
Expand description
A Structure which represent an http request with a fully loaded body
Implementations
sourceimpl SyncRequest
impl SyncRequest
sourcepub fn method(&self) -> &Method
pub fn method(&self) -> &Method
Returns a reference to the associated HTTP method.
Examples
let request: Request<()> = Request::default();
assert_eq!(*request.method(), Method::GET);
sourcepub fn method_mut(&mut self) -> &mut Method
pub fn method_mut(&mut self) -> &mut Method
Returns a mutable reference to the associated HTTP method.
Examples
let mut request: Request<()> = Request::default();
*request.method_mut() = Method::PUT;
assert_eq!(*request.method(), Method::PUT);
sourcepub fn uri(&self) -> &Uri
pub fn uri(&self) -> &Uri
Returns a reference to the associated URI.
Examples
let request: Request<()> = Request::default();
assert_eq!(*request.uri(), *"/");
sourcepub fn uri_mut(&mut self) -> &mut Uri
pub fn uri_mut(&mut self) -> &mut Uri
Returns a mutable reference to the associated URI.
Examples
let mut request: Request<()> = Request::default();
*request.uri_mut() = "/hello".parse().unwrap();
assert_eq!(*request.uri(), *"/hello");
sourcepub fn version(&self) -> Version
pub fn version(&self) -> Version
Returns the associated version.
Examples
let request: Request<()> = Request::default();
assert_eq!(request.version(), Version::HTTP_11);
sourcepub fn version_mut(&mut self) -> &mut Version
pub fn version_mut(&mut self) -> &mut Version
Returns a mutable reference to the associated version.
Examples
let mut request: Request<()> = Request::default();
*request.version_mut() = Version::HTTP_2;
assert_eq!(request.version(), Version::HTTP_2);
sourcepub fn headers_map(&self) -> &HeaderMap<HeaderValue>
pub fn headers_map(&self) -> &HeaderMap<HeaderValue>
Returns a reference to the associated header field map.
Examples
let request: Request<()> = Request::default();
assert!(request.headers().is_empty());
sourcepub fn headers_map_mut(&mut self) -> &mut HeaderMap<HeaderValue>
pub fn headers_map_mut(&mut self) -> &mut HeaderMap<HeaderValue>
Returns a mutable reference to the associated header field map.
Examples
let mut request: Request<()> = Request::default();
request.headers_mut().insert(HOST, HeaderValue::from_static("world"));
assert!(!request.headers().is_empty());
sourcepub fn parsed_header(&self) -> Headers
pub fn parsed_header(&self) -> Headers
Clone the HeaderMap and convert it to a more dev-friendly Headers struct
sourcepub fn insert_parsed_headers(&mut self, headers: Headers)
pub fn insert_parsed_headers(&mut self, headers: Headers)
Insert a dev-friendly Headers to the HeaderMap
sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Returns a reference to the associated extensions.
Examples
let request: Request<()> = Request::default();
assert!(request.extensions().get::<i32>().is_none());
sourcepub fn extensions_mut(&mut self) -> &mut Extensions
pub fn extensions_mut(&mut self) -> &mut Extensions
Returns a mutable reference to the associated extensions.
Examples
let mut request: Request<()> = Request::default();
request.extensions_mut().insert("hello");
assert_eq!(request.extensions().get(), Some(&"hello"));
sourcepub fn body(&self) -> &Vec<u8> ⓘ
pub fn body(&self) -> &Vec<u8> ⓘ
Returns a reference to the associated HTTP body.
Examples
let request: Request<String> = Request::default();
assert!(request.body().is_empty());
sourcepub fn body_mut(&mut self) -> &mut Vec<u8> ⓘ
pub fn body_mut(&mut self) -> &mut Vec<u8> ⓘ
Returns a mutable reference to the associated HTTP body.
Examples
let mut request: Request<String> = Request::default();
request.body_mut().push_str("hello world");
assert!(!request.body().is_empty());
sourcepub fn addons(&self) -> &RequestAddonCollection
pub fn addons(&self) -> &RequestAddonCollection
Returns a reference to the request add-ons
sourcepub fn addons_mut(&mut self) -> &mut RequestAddonCollection
pub fn addons_mut(&mut self) -> &mut RequestAddonCollection
Returns a reference to the request add-ons