2018-11-03 09:42:48 +00:00
|
|
|
use failure::*;
|
|
|
|
use std::collections::HashMap;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::json_schema::*;
|
|
|
|
use crate::api_info::*;
|
|
|
|
use serde_json::{json, Value};
|
|
|
|
|
|
|
|
|
|
|
|
fn test_api_handler(param: Value) -> Result<Value, Error> {
|
|
|
|
println!("This is a test {}", param);
|
|
|
|
|
|
|
|
// let force: Option<bool> = Some(false);
|
|
|
|
|
|
|
|
//if let Some(force) = param.force {
|
|
|
|
//}
|
|
|
|
|
|
|
|
let _force = param["force"].as_bool()
|
|
|
|
.ok_or_else(|| format_err!("missing parameter 'force'"))?;
|
|
|
|
|
|
|
|
if let Some(_force) = param["force"].as_bool() {
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ok(json!(null))
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-11-03 14:10:21 +00:00
|
|
|
pub fn router() -> MethodInfo {
|
2018-11-03 09:42:48 +00:00
|
|
|
|
2018-11-03 14:10:21 +00:00
|
|
|
let route = MethodInfo::new()
|
|
|
|
.get(ApiMethod {
|
|
|
|
handler: test_api_handler,
|
|
|
|
description: "This is a simple test.",
|
|
|
|
parameters: parameter!{
|
|
|
|
force => Boolean!{
|
2018-11-06 12:10:10 +00:00
|
|
|
optional => true,
|
2018-11-03 14:10:21 +00:00
|
|
|
description => "Test for boolean options."
|
|
|
|
}
|
|
|
|
},
|
|
|
|
returns: Jss::Null,
|
|
|
|
});
|
2018-11-03 09:42:48 +00:00
|
|
|
|
2018-11-03 14:10:21 +00:00
|
|
|
route
|
2018-11-03 09:42:48 +00:00
|
|
|
}
|
2018-11-03 14:10:21 +00:00
|
|
|
|
|
|
|
|