pub struct Request {
pub method: Method,
pub path: String,
pub params: Option<HashMap<String, String>>,
pub headers: HashMap<String, String>,
pub body: Option<String>,
pub path_vars: HashMap<String, String>,
}Fields§
§method: Method§path: String§params: Option<HashMap<String, String>>§headers: HashMap<String, String>§body: Option<String>§path_vars: HashMap<String, String>Implementations§
Source§impl Request
impl Request
Sourcepub fn new(request: &str) -> Result<Self>
pub fn new(request: &str) -> Result<Self>
§Examples
use request_http_parser::parser::{Method,Request};
let req_str = format!(
"POST /login HTTP/1.1\r\n\
Content-Type: application/json\r\n\
User-Agent: Test\r\n\
Content-Length: {}\r\n\\r\n\
{{\"username\": \"{}\",\"password\": \"{}\"}}",
44, "crisandolin", "rumahorbo");
let req = Request::new(&req_str).unwrap();
assert_eq!(Method::POST, req.method);
assert_eq!("/login", req.path); 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