1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::collections::HashMap;

pub struct Request{
    pub method:     String,
    pub path:       String,
    pub body:       String,
    pub headers:    HashMap<String, String>
}

impl Request {
    pub fn get_method(&self) -> &String{
        return &self.method;
    }

    pub fn get_path(&self) -> &String{
        return &self.path;
    }

    pub fn get_body(&self) -> &String{
        return &self.body;
    }
    
    pub fn get_header(&self) -> &Self { self }

    pub fn get_key(&self, key: &str) -> String{
        match self.headers.get(key){
            Some(key) => {
                return String::from(key);
            }
            None => { panic!("Key does not exist") }
        }
    }
    pub fn key_exist(&self, key: &str) -> bool {
        match self.headers.get(key){
            Some(_) => { return true }
            None => { return false }
        }
    }

}