diff options
Diffstat (limited to 'src/http/mod.rs')
| -rw-r--r-- | src/http/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs index a77869e..4291021 100644 --- a/src/http/mod.rs +++ b/src/http/mod.rs @@ -33,7 +33,21 @@ impl Req { pub fn query_get(&self, key: &str) -> Option<String> { self.query_pairs.iter().find(|(k, _)| k == key).map(|(_, v)| v.clone()) } + /// Reading a cookie off a request is internal plumbing; the auth tests need it in order to forge one. + /// + /// Module-internal in a production build, `pub` only under `test-support`: + /// one body behind two visibility declarations, exactly one of which compiles. + #[cfg(feature = "test-support")] pub fn cookie(&self, name: &str) -> Option<String> { + Self::cookie_impl(self, name) + } + + #[cfg(not(feature = "test-support"))] + pub(crate) fn cookie(&self, name: &str) -> Option<String> { + Self::cookie_impl(self, name) + } + + fn cookie_impl(&self, name: &str) -> Option<String> { self.cookies.iter().find(|(k, _)| k == name).map(|(_, v)| v.clone()) } } |
