From 82f8df963e3b02a2f7f1b8c031c36a765096bef5 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 15 Aug 2019 11:02:08 +0200 Subject: [PATCH] api: router: return Map on lookup Instead of a Value, makes it easier to use the parameters later on. Signed-off-by: Wolfgang Bumiller --- proxmox-api/src/router.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxmox-api/src/router.rs b/proxmox-api/src/router.rs index 606ea996..4fbdbbe6 100644 --- a/proxmox-api/src/router.rs +++ b/proxmox-api/src/router.rs @@ -2,7 +2,7 @@ use std::collections::HashMap; -use serde_json::{json, Value}; +use serde_json::{json, map::Map, Value}; use super::ApiHandler; @@ -59,12 +59,12 @@ where /// Lookup a path in the router. Note that this returns a tuple: the router we ended up on /// (providing methods and subdirectories available for the given path), and optionally a json /// value containing all the matched parameters ([`SubRoute::Parameter`] subdirectories). - pub fn lookup>(&self, path: T) -> Option<(&Self, Option)> { + pub fn lookup>(&self, path: T) -> Option<(&Self, Option>)> { self.lookup_do(path.as_ref()) } // The actual implementation taking the parameter as &str - fn lookup_do(&self, path: &str) -> Option<(&Self, Option)> { + fn lookup_do(&self, path: &str) -> Option<(&Self, Option>)> { let mut matched_params = None; let mut matched_wildcard: Option = None; @@ -107,7 +107,7 @@ where ); } - Some((this, matched_params.map(Value::Object))) + Some((this, matched_params)) } pub fn api_dump(&self) -> Value {