mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-23 09:40:20 +00:00
RpcEnvironment: add environment type enum RpcEnvironmentType
This commit is contained in:
parent
084ccdd590
commit
23db39488f
@ -4,12 +4,16 @@ use std::collections::HashMap;
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
pub struct RestEnvironment {
|
pub struct RestEnvironment {
|
||||||
|
env_type: RpcEnvironmentType,
|
||||||
result_attributes: HashMap<String, Value>,
|
result_attributes: HashMap<String, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RestEnvironment {
|
impl RestEnvironment {
|
||||||
pub fn new() -> Self {
|
pub fn new(env_type: RpcEnvironmentType) -> Self {
|
||||||
Self { result_attributes: HashMap::new() }
|
Self {
|
||||||
|
result_attributes: HashMap::new(),
|
||||||
|
env_type,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,4 +26,8 @@ impl RpcEnvironment for RestEnvironment {
|
|||||||
fn get_result_attrib(&self, name: &str) -> Option<&Value> {
|
fn get_result_attrib(&self, name: &str) -> Option<&Value> {
|
||||||
self.result_attributes.get(name)
|
self.result_attributes.get(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn env_type(&self) -> RpcEnvironmentType {
|
||||||
|
self.env_type
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ pub fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> BoxFut {
|
|||||||
println!("REQUEST {} {}", method, path);
|
println!("REQUEST {} {}", method, path);
|
||||||
println!("COMPO {:?}", components);
|
println!("COMPO {:?}", components);
|
||||||
|
|
||||||
let mut rpcenv = RestEnvironment::new();
|
let rpcenv = RestEnvironment::new(RpcEnvironmentType::PRIVILEDGED);
|
||||||
|
|
||||||
if comp_len >= 1 && components[0] == "api2" {
|
if comp_len >= 1 && components[0] == "api2" {
|
||||||
println!("GOT API REQUEST");
|
println!("GOT API REQUEST");
|
||||||
|
Loading…
Reference in New Issue
Block a user