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
use crate::kernel::singleton::Singleton;
use crate::kernel::singleton::new_singleton;
use std::collections::HashMap;

pub struct HttpCoreHandler { }

impl HttpCoreHandler {
    pub fn set_driver(driver: Box<dyn HttpCore>) {
        unsafe {
            HTTP_CORE.set_instance(driver);
        }
    }

    // TODO Implement Option Validation for Clean Message
    pub fn get_driver() -> &'static Box<dyn HttpCore> {
        unsafe {
            return HTTP_CORE.get_instance();
        }
    }
}

pub trait HttpCore {
    fn handle(&self);
    fn get_request_headers(&self) -> HashMap<String, String>;
    fn get_post_data(&self) -> String;
}

static mut HTTP_CORE : Singleton<Box<dyn HttpCore>> = new_singleton();