move rpc environment implementation to separate files

This commit is contained in:
Dietmar Maurer
2019-01-26 15:08:02 +01:00
parent 6049b71f41
commit 0f253593c6
6 changed files with 58 additions and 46 deletions

View File

@ -2,6 +2,7 @@ use crate::tools;
use crate::api::schema::*;
use crate::api::router::*;
use crate::api::config::*;
use super::environment::RestEnvironment;
use super::formatter::*;
use std::fmt;
@ -26,27 +27,6 @@ use hyper::service::{Service, NewService};
use hyper::rt::{Future, Stream};
use hyper::header;
struct RestEnvironment {
result_attributes: HashMap<String, Value>,
}
impl RestEnvironment {
fn new() -> Self {
Self { result_attributes: HashMap::new() }
}
}
impl RpcEnvironment for RestEnvironment {
fn set_result_attrib(&mut self, name: &str, value: Value) {
self.result_attributes.insert(name.into(), value);
}
fn get_result_attrib(&self, name: &str) -> Option<&Value> {
self.result_attributes.get(name)
}
}
pub struct RestServer {
pub api_config: Arc<ApiConfig>,
}