diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-08-19 19:26:53 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-08-19 19:26:53 +0200 |
commit | f5bdd3f122138e6ea0a8eafedfaf900862070507 (patch) | |
tree | 44f9067f4716aaebe1f2e0cf81ad70a5d7a34658 | |
parent | cabd6e0a688399b33e2df6960f55aeb8134993c3 (diff) | |
download | rust-zotapi-f5bdd3f122138e6ea0a8eafedfaf900862070507.tar.gz rust-zotapi-f5bdd3f122138e6ea0a8eafedfaf900862070507.tar.bz2 rust-zotapi-f5bdd3f122138e6ea0a8eafedfaf900862070507.zip |
Generalize channel_stream into internal helper function.
-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 |