pub struct Request {
pub args: HashMap<String, String>,
pub data: HashMap<String, String>,
pub params: HashMap<String, String>,
/* private fields */
}
Expand description
HTTP Request
Fields§
§args: HashMap<String, String>
§data: HashMap<String, String>
§params: HashMap<String, String>
Implementations§
Source§impl Request
impl Request
Sourcepub fn new(
method: &str,
uri: &str,
headers: HashMap<String, String>,
body: &[u8],
) -> Self
pub fn new( method: &str, uri: &str, headers: HashMap<String, String>, body: &[u8], ) -> Self
Create a new Request
§Example
use std::collections::HashMap;
use haro::Request;
let headers = HashMap::new();
let body = &Vec::new();
let mut req = Request::new("get", "/", headers, body);
Sourcepub fn method(&self) -> &str
pub fn method(&self) -> &str
HTTP method for current Request
Examples found in repository?
More examples
Sourcepub fn headers(&self) -> &HeaderMap<HeaderValue>
pub fn headers(&self) -> &HeaderMap<HeaderValue>
HTTP headers for current Request
HTTP cookies for current Request
Examples found in repository?
examples/cookie/main.rs (line 33)
31fn session_middleware(next: DynHandler) -> DynHandler {
32 Arc::new(move |req: Request| -> Response {
33 let cookies = req.cookies();
34 println!("get cookies: {cookies:?}");
35
36 let mut res = next(req);
37
38 let cookie1 = Cookie::build("foo", "bar").finish();
39 let cookie2 = Cookie::build("bar", "baz")
40 .domain("example.coom")
41 .path("/")
42 .secure(true)
43 .http_only(true)
44 .finish();
45 res = res.header(SET_COOKIE, &cookie1.to_string());
46 res.header(SET_COOKIE, &cookie2.to_string())
47 })
48}
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