From f5bdd3f122138e6ea0a8eafedfaf900862070507 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 19 Aug 2018 19:26:53 +0200 Subject: Generalize channel_stream into internal helper function. --- src/lib.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 0026bf0..d87e6d0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,7 +38,15 @@ pub struct Client { impl Client { pub fn channel_stream(&self) -> Result { - let url = self.url(ZOTAPI_CHANNEL_STREAM_PATH); + self.fetch_stream(ZOTAPI_CHANNEL_STREAM_PATH) + } + + fn url(&self, path: &str) -> String { + self.base_url.clone() + path + } + + fn fetch_stream(&self, path: &str) -> Result { + let url = self.url(path); let mut res = self.inner.get(&url) .header(Accept(vec![qitem(mime::APPLICATION_JSON)])) .basic_auth(self.user.clone(), Some(self.pw.clone())) @@ -54,10 +62,6 @@ impl Client { _ => Err(Error::Unknown) } } - - fn url(&self, path: &str) -> String { - self.base_url.clone() + path - } } pub fn client(url: &str, user: &str, pw: &str) -> Client -- cgit v1.2.3