better cookie support #20
siddhantk232
started this conversation in
Ideas
Replies: 1 comment
-
IntoCookieimpl In {
// note that this is private
fn add_cookie_raw(&self, s: String) {
self.cookies.push(s)
}
pub fn add_cookie<K: AsRef<str>, V: AsRef<str>(&self, key: K, value: V) {}
}
pub trait IntoCookie {
fn to_cookie(&self) -> String;
fn add_cookie_into(in_: &In) {
in_.add_cookie_raw(self.to_cookie())
}
}
// someday if we decide to expose our own cookie struct
impl IntoCookie for OurCookie {}
// we will support cookie crate behind a feature flag
#[cfg(feature = "cookie")]
impl IntoCookie for cookie::Cookie {} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Also, not happy with the
RC<RefCell<Vec<Cookie>>>type forIn::set_cookies. Should replace this with a blanketCookieStoreand move theIn::add_cookie()method there.Functions that want to manipulate cookies should then take
CookieStoreand not the wholeInthis way we avoid unnecessary copy.Beta Was this translation helpful? Give feedback.
All reactions