From 50ef8a77be694565eed502b602cf7fbd339bf20a Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Tue, 3 Oct 2023 17:56:17 -0400 Subject: [PATCH] Remove a legacy file --- file-service/src/cookies.rs | 61 ------------------------------------- 1 file changed, 61 deletions(-) delete mode 100644 file-service/src/cookies.rs diff --git a/file-service/src/cookies.rs b/file-service/src/cookies.rs deleted file mode 100644 index 3e5c45b..0000000 --- a/file-service/src/cookies.rs +++ /dev/null @@ -1,61 +0,0 @@ -use iron::headers; -use std::collections::HashMap; - -#[derive(Clone, Debug)] -pub struct Cookie { - pub name: String, - pub value: String, -} - -impl From<&str> for Cookie { - fn from(s: &str) -> Cookie { - let parts: Vec<&str> = s.split("=").collect(); - Cookie { - name: String::from(parts[0]), - value: String::from(parts[1]), - } - } -} - -impl From<&String> for Cookie { - fn from(s: &String) -> Cookie { - Cookie::from(s.as_str()) - } -} - -impl From for Cookie { - fn from(s: String) -> Cookie { - Cookie::from(s.as_str()) - } -} - -#[derive(Debug)] -pub struct CookieJar(HashMap); - -impl CookieJar { - pub fn new() -> CookieJar { - CookieJar(HashMap::new()) - } - - pub fn add_cookie(&mut self, name: String, value: Cookie) { - self.0.insert(name, value); - } - - pub fn lookup(&self, name: &str) -> Option<&Cookie> { - self.0.get(name) - } -} - -// Some(Cookie(["auth=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJhYzNhNDZjNi0zZmExLTRkMGEtYWYxMi1lN2QzZmVmZGM4NzgiLCJhdWQiOiJzYXZhbm5pIiwiZXhwIjoxNjIxMzUxNDM2LCJpc3MiOiJzYXZhbm5pIiwiaWF0IjoxNTg5NzI5MDM2LCJzdWIiOiJodHRwczovL3NhdmFubmkubHVtaW5lc2NlbnQtZHJlYW1zLmNvbS9maWxlLXNlcnZpY2UvIiwicGVybXMiOlsiYWRtaW4iXX0.8zjAbZ7Ut0d6EcDeyik39GKhXvH4qkMDdaiQVNKWiuM"])) -impl From<&headers::Cookie> for CookieJar { - fn from(c: &headers::Cookie) -> CookieJar { - let jar = CookieJar::new(); - - let headers::Cookie(cs) = c; - cs.iter().fold(jar, |mut jar, c_| { - let cookie = Cookie::from(c_); - jar.add_cookie(cookie.name.clone(), cookie); - jar - }) - } -}