src/api2/types.rs: use separate file for schema definitions
This commit is contained in:
@ -1,10 +1,4 @@
|
||||
use failure::*;
|
||||
|
||||
use crate::tools;
|
||||
use crate::api_schema::*;
|
||||
use crate::api_schema::router::*;
|
||||
use lazy_static::lazy_static;
|
||||
use std::sync::Arc;
|
||||
|
||||
mod tasks;
|
||||
mod time;
|
||||
@ -13,23 +7,6 @@ mod dns;
|
||||
mod syslog;
|
||||
mod services;
|
||||
|
||||
lazy_static!{
|
||||
|
||||
pub static ref NODE_SCHEMA: Arc<Schema> = Arc::new(
|
||||
StringSchema::new("Node name (or 'localhost')")
|
||||
.format(
|
||||
Arc::new(ApiStringFormat::VerifyFn(|node| {
|
||||
if node == "localhost" || node == tools::nodename() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(format_err!("no such node '{}'", node))
|
||||
}
|
||||
}))
|
||||
)
|
||||
.into()
|
||||
);
|
||||
}
|
||||
|
||||
pub fn router() -> Router {
|
||||
|
||||
let route = Router::new()
|
||||
|
Reference in New Issue
Block a user