api: pass RpcEnvirnment to api handlers
This commit is contained in:
@ -51,7 +51,11 @@ fn read_etc_resolv_conf() -> Result<Value, Error> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn update_dns(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn update_dns(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
lazy_static! {
|
||||
static ref MUTEX: Arc<Mutex<usize>> = Arc::new(Mutex::new(0));
|
||||
@ -93,7 +97,11 @@ fn update_dns(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
Ok(Value::Null)
|
||||
}
|
||||
|
||||
fn get_dns(_param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn get_dns(
|
||||
_param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
read_etc_resolv_conf()
|
||||
}
|
||||
|
@ -6,7 +6,11 @@ use crate::api::router::*;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
|
||||
fn get_network_config(_param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn get_network_config(
|
||||
_param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
Ok(json!({}))
|
||||
}
|
||||
|
@ -72,7 +72,11 @@ fn dump_journal(
|
||||
Ok((count, lines))
|
||||
}
|
||||
|
||||
fn get_syslog(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn get_syslog(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let (count, lines) = dump_journal(
|
||||
param["start"].as_u64(),
|
||||
@ -81,7 +85,7 @@ fn get_syslog(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
param["until"].as_str(),
|
||||
param["service"].as_str())?;
|
||||
|
||||
//fixme: $restenv->set_result_attrib('total', $count);
|
||||
rpcenv.set_result_attrib("total", Value::from(count));
|
||||
|
||||
Ok(json!(lines))
|
||||
}
|
||||
|
@ -14,7 +14,11 @@ fn read_etc_localtime() -> Result<String, Error> {
|
||||
Ok(line.trim().to_owned())
|
||||
}
|
||||
|
||||
fn get_time(_param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn get_time(
|
||||
_param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let datetime = Local::now();
|
||||
let offset = datetime.offset();
|
||||
@ -32,7 +36,11 @@ extern "C" { fn tzset(); }
|
||||
|
||||
// Note:: this needs root rights ??
|
||||
|
||||
fn set_timezone(param: Value, _info: &ApiMethod) -> Result<Value, Error> {
|
||||
fn set_timezone(
|
||||
param: Value,
|
||||
_info: &ApiMethod,
|
||||
_rpcenv: &mut RpcEnvironment,
|
||||
) -> Result<Value, Error> {
|
||||
|
||||
let timezone = tools::required_string_param(¶m, "timezone")?;
|
||||
|
||||
|
Reference in New Issue
Block a user