pub struct Request { /* private fields */ }Expand description
Represents an HTTP request.
§Fields
method: The HTTP method of the request (e.g., GET, POST).host: The host of the request (e.g., example.com).path: The path of the request (e.g., /api/v1/resource).query: The query string of the request (e.g., ?key=value).headers: A collection of HTTP headers as key-value pairs.body: The binary body of the request.
Implementations§
Source§impl Request
impl Request
Sourcepub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Request
pub fn set_header<K, V>(&mut self, key: K, value: V) -> &mut Request
Adds a header to the request.
This function inserts a key-value pair into the request headers.
The key and value are converted into String, allowing for efficient handling of both owned and borrowed string data.
§Parameters
key: The header key, which will be converted into aString.value: The value of the header, which will be converted into aString.
§Returns
- Returns a mutable reference to the current instance (
&mut Self), allowing for method chaining.
Source§impl Request
impl Request
pub fn get_method(&self) -> &String
pub fn get_mut_method(&mut self) -> &mut String
pub fn set_method(&mut self, val: String) -> &mut Request
pub fn get_host(&self) -> &String
pub fn get_mut_host(&mut self) -> &mut String
pub fn set_host(&mut self, val: String) -> &mut Request
pub fn get_path(&self) -> &String
pub fn get_mut_path(&mut self) -> &mut String
pub fn set_path(&mut self, val: String) -> &mut Request
pub fn get_query(&self) -> &HashMap<String, String>
pub fn get_mut_query(&mut self) -> &mut HashMap<String, String>
pub fn set_query(&mut self, val: HashMap<String, String>) -> &mut Request
pub fn get_headers(&self) -> &HashMap<String, String>
pub fn get_mut_headers(&mut self) -> &mut HashMap<String, String>
pub fn set_headers(&mut self, val: HashMap<String, String>) -> &mut Request
pub fn get_body(&self) -> &Vec<u8> ⓘ
pub fn get_mut_body(&mut self) -> &mut Vec<u8> ⓘ
pub fn set_body(&mut self, val: Vec<u8>) -> &mut Request
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more