Skip to main content

lava_http/request/
req.rs

1use std::collections::HashMap;
2
3pub struct Request{
4    pub method:     String,
5    pub path:       String,
6    pub body:       String,
7    pub headers:    HashMap<String, String>
8}
9
10impl Request {
11    pub fn get_method(&self) -> &String{
12        return &self.method;
13    }
14
15    pub fn get_path(&self) -> &String{
16        return &self.path;
17    }
18
19    pub fn get_body(&self) -> &String{
20        return &self.body;
21    }
22    
23    pub fn get_header(&self) -> &Self { self }
24
25    pub fn get_key(&self, key: &str) -> String{
26        match self.headers.get(key){
27            Some(key) => {
28                return String::from(key);
29            }
30            None => { panic!("Key does not exist") }
31        }
32    }
33    pub fn key_exist(&self, key: &str) -> bool {
34        match self.headers.get(key){
35            Some(_) => { return true }
36            None => { return false }
37        }
38    }
39
40}
41