diff --git a/src/api3.rs b/src/api3.rs index 6549011b..40789ace 100644 --- a/src/api3.rs +++ b/src/api3.rs @@ -6,15 +6,7 @@ use crate::json_schema::*; use crate::api_info::*; use serde_json::{json, Value}; -use futures::future::*; -use tokio::prelude::*; -use tokio::fs::File; -use tokio::io; -use tokio_codec; - -use hyper::{Method, Body, Request, Response, Server, StatusCode}; - -fn test_sync_api_handler(param: Value, info: &ApiMethod) -> Result { +fn test_sync_api_handler(param: Value, _info: &ApiMethod) -> Result { println!("This is a test {}", param); // let force: Option = Some(false); @@ -32,54 +24,11 @@ fn test_sync_api_handler(param: Value, info: &ApiMethod) -> Result Ok(json!(null)) } -fn test_async_api_handler( - param: Value, - info: &ApiMethod -) -> Box, Error = Error> + Send> { - println!("This is a test {}", param); - - let task = lazy(|| { - println!("A LAZY TASK"); - - - let dump_file = File::open("/etc/network/interfaces") - .and_then(|file| { - let file = std::io::BufReader::new(file); - let mut linenr = 1; - tokio::io::lines(file).for_each(move |line| { - println!("LINE {}: {}", linenr, line); - linenr += 1; - ok(()) - }) - }).map_err(|err| ()); - - //tokio::spawn(dump_file); - - let dump_file2 = File::open("/etc/network/interfaces") - .and_then(|file| { - tokio_codec::FramedRead::new(file, tokio_codec::BytesCodec::new()).for_each(|data| { - println!("DATA {:?}", data); - ok(()) - }) - }).map_err(|err| ()); // fixme: log error - - tokio::spawn(dump_file2); - - let mut resp = Response::new(Body::from("A LAZY TASKs RESPONSE")); - *resp.status_mut() = StatusCode::OK; - - ok(resp) - }); - - Box::new(task) -} - pub fn router() -> MethodInfo { let route = MethodInfo::new() .get(ApiMethod { handler: test_sync_api_handler, - async_handler: test_async_api_handler, description: "This is a simple test.", parameters: parameter!{ force => Boolean!{ diff --git a/src/api_info.rs b/src/api_info.rs index ebed6ddf..05969dc3 100644 --- a/src/api_info.rs +++ b/src/api_info.rs @@ -1,10 +1,9 @@ use std::fmt; use failure::*; -use futures::future::*; use crate::json_schema::*; use serde_json::{Value}; -use hyper::{Body, Response, StatusCode}; +use hyper::{StatusCode}; use std::collections::HashMap; @@ -13,7 +12,6 @@ pub struct ApiMethod { pub parameters: Jss, pub returns: Jss, pub handler: fn(Value, &ApiMethod) -> Result, - pub async_handler: fn(Value, &ApiMethod) -> Box, Error = Error> + Send> } #[derive(Debug, Fail)] diff --git a/src/api_server.rs b/src/api_server.rs index d6e98788..38d8d53c 100644 --- a/src/api_server.rs +++ b/src/api_server.rs @@ -1,19 +1,9 @@ use std::collections::HashMap; use std::path::{PathBuf}; use crate::api_info::*; -use crate::json_schema::*; +//use crate::json_schema::*; -use futures::future::{self, Either}; - -use tokio::fs::File; -use tokio_codec; - - -use hyper::http::request::Parts; -use hyper::{Method, Body, Request, Response, Server, StatusCode}; -use hyper::rt::{Future, Stream}; -use hyper::service::{service_fn, NewService}; -use hyper::header; +use hyper::{Method}; pub struct ApiServer { basedir: PathBuf, diff --git a/src/json_schema.rs b/src/json_schema.rs index 29b27a77..7bbd945f 100644 --- a/src/json_schema.rs +++ b/src/json_schema.rs @@ -166,7 +166,7 @@ fn parse_simple_value(value_str: &str, schema: &Jss) -> Result { Jss::Null => { bail!("internal error - found Null schema."); } - Jss::Boolean(jss_boolean) => { + Jss::Boolean(_jss_boolean) => { let res = match value_str.to_lowercase().as_str() { "1" | "on" | "yes" | "true" => true, "0" | "off" | "no" | "false" => false, @@ -219,7 +219,7 @@ fn parse_simple_value(value_str: &str, schema: &Jss) -> Result { bail!("value is not defined in the enumeration."); } } - ApiStringFormat::Complex(ref subschema) => { + ApiStringFormat::Complex(ref _subschema) => { bail!("implement me!"); } }