3 use crate::api
::schema
::*;
4 use crate::api
::router
::*;
5 use serde_json
::{json, Value}
;
14 use lazy_static
::lazy_static
;
15 use crate::tools
::common_regex
;
17 // common schema definitions
20 pub static ref IP_FORMAT
: Arc
<ApiStringFormat
> = ApiStringFormat
::Pattern(&common_regex
::IP_REGEX
).into();
27 fn test_sync_api_handler(param
: Value
, _info
: &ApiMethod
) -> Result
<Value
, Error
> {
28 println
!("This is a test {}", param
);
30 // let force: Option<bool> = Some(false);
32 //if let Some(force) = param.force {
35 let _force
= param
["force"].as_bool()
36 .ok_or_else(|| format_err
!("missing parameter 'force'"))?
;
38 if let Some(_force
) = param
["force"].as_bool() {
44 pub fn router() -> Router
{
46 let route4
= Router
::new()
49 println
!("This is a clousure handler: {}", param
);
53 ObjectSchema
::new("Another Endpoint."))
54 .returns(Schema
::Null
));
57 let nodeinfo
= Router
::new()
59 test_sync_api_handler
,
60 ObjectSchema
::new("This is a simple test.")
61 .optional("force", BooleanSchema
::new("Test for boolean options")))
63 .subdir("subdir3", route4
);
65 let nodes
= Router
::new()
66 .subdir("localhost", node
::router());
69 let route
= Router
::new()
75 {"subdir": "subscription"}
,
76 {"subdir": "version"}
,
78 ObjectSchema
::new("Directory index.")))
79 .subdir("admin", admin
::router())
80 .subdir("config", config
::router())
81 .subdir("nodes", nodes
)
82 .subdir("subscription", subscription
::router())
83 .subdir("version", version
::router());