diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -38,7 +38,15 @@ pub struct Client { impl Client { pub fn channel_stream(&self) -> Result<String, Error> { - 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<String, Error> { + 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 |