3 use crate::api
::schema
::*;
4 use crate::api
::router
::*;
5 use serde_json
::{json, Value}
;
12 fn test_sync_api_handler(param
: Value
, _info
: &ApiMethod
) -> Result
<Value
, Error
> {
13 println
!("This is a test {}", param
);
15 // let force: Option<bool> = Some(false);
17 //if let Some(force) = param.force {
20 let _force
= param
["force"].as_bool()
21 .ok_or_else(|| format_err
!("missing parameter 'force'"))?
;
23 if let Some(_force
) = param
["force"].as_bool() {
29 pub fn router() -> Router
{
31 let route4
= Router
::new()
34 println
!("This is a clousure handler: {}", param
);
38 ObjectSchema
::new("Another Endpoint."))
39 .returns(Schema
::Null
));
42 let nodeinfo
= Router
::new()
44 test_sync_api_handler
,
45 ObjectSchema
::new("This is a simple test.")
46 .optional("force", BooleanSchema
::new("Test for boolean options")))
48 .subdir("subdir3", route4
);
50 let nodes
= Router
::new()
51 .match_all("node", nodeinfo
);
54 let route
= Router
::new()
60 {"subdir": "subscription"}
,
61 {"subdir": "version"}
,
63 ObjectSchema
::new("Directory index.")))
64 .subdir("admin", admin
::router())
65 .subdir("config", config
::router())
66 .subdir("nodes", nodes
)
67 .subdir("subscription", subscription
::router())
68 .subdir("version", version
::router());