aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 31e1bb2..60ac388 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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]