lest 0.2.1

A modular approach to a web server. Based on actix-web.
Documentation
#[derive(Debug)]
/// A `Cookie` is a representation of an HTTP cookie.
pub struct Cookie {
    pub name: String,
    pub value: String,
    pub expires: Option<String>
}

#[allow(dead_code)]
impl Cookie {
    /// Create a new cookie.
    pub fn new(name: String, value: String) -> Self {
        Cookie {
            name,
            value,
            expires: None
        }
    }

    /// Set the expires header of the cookie.
    pub fn set_expires(&mut self, expires: String) {
        self.expires = Some(expires);
    }

    /// Build the cookie.
    pub fn build(&self) -> String {
        let mut cookie = String::new();
        cookie.push_str(&format!("{}={}; ", self.name, self.value));
        if let Some(expires) = &self.expires {
            cookie.push_str(&format!("Expires={}; ", expires));
        }
        cookie
    }
}

#[derive(Debug)]
/// A `CookieBuilder` is a builder for creating a cookie header.
pub struct CookieBuilder {
    pub cookies: Vec<Cookie>,
    pub expires: Option<String>,
}


#[allow(dead_code)]
impl CookieBuilder {
    /// Create a new `CookieBuilder`.
    pub fn new() -> Self {
        CookieBuilder {
            cookies: Vec::new(),
            expires: None
        }
    }

    /// Add a cookie to the builder.
    pub fn add_cookie(&mut self, cookie: Cookie) {
        self.cookies.push(cookie);
    }

    /// Set the expires header of the builder.
    pub fn set_expires(&mut self, expires: String) {
        self.expires = Some(expires);
    }

    /// Build the cookie header.
    pub fn build(&self) -> String {
        let mut cookies = String::new();
        for cookie in &self.cookies {
            cookies.push_str(&cookie.build());
        }
        if let Some(expires) = &self.expires {
            cookies.push_str(&format!("Expires={}; ", expires));
        }
        cookies
    }
}