diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2018-08-07 12:11:39 +0200 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2018-08-07 12:11:39 +0200 |
commit | fb3d996d90f9e496654ae4485b9d036dcc7baf8a (patch) | |
tree | 0af403e71890557a134bad875349cffffe9d31c5 /src | |
parent | 1a7686fa596e9b93239edfac4db07b4b083f18a4 (diff) | |
download | rust-zotapi-fb3d996d90f9e496654ae4485b9d036dcc7baf8a.tar.gz rust-zotapi-fb3d996d90f9e496654ae4485b9d036dcc7baf8a.tar.bz2 rust-zotapi-fb3d996d90f9e496654ae4485b9d036dcc7baf8a.zip |
First iteration of getting channel stream from server.
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -1,3 +1,35 @@ +extern crate reqwest; + +use std::io::Read; + +const ZOTAPI_CHANNEL_STREAM_PATH : &str = "/api/z/1.0/channel/stream"; + +pub struct Client { + base_url: String, +} + +impl Client { + pub fn channel_stream(&self) -> String { + let mut res = reqwest::get(&self.channel_stream_url()).unwrap(); + let mut body = String::new(); + res.read_to_string(&mut body).unwrap(); + body + } + + fn channel_stream_url(&self) -> String { + self.base_url.clone() + ZOTAPI_CHANNEL_STREAM_PATH + } +} + +pub fn client<T>(url: T) -> Client +where + T: Into<String> +{ + Client { + base_url: url.into(), + } +} + #[cfg(test)] mod tests { #[test] |