api: pass RpcEnvirnment to api handlers

This commit is contained in:
Dietmar Maurer
2019-01-26 14:50:37 +01:00
parent d96d82736d
commit 6049b71f41
18 changed files with 252 additions and 109 deletions

View File

@ -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))
}