pub fn handle_map(&self, domain: &str, map: &str, keyname: Option<&str>, query: &HashMap<String, String>) -> WarpResult {
        // lookup domain in config
        let domain = match self.inner.config.find_domain(&domain) {
            None => return Err(json_error(StatusCode::BAD_REQUEST, None, "Domain not found")),
            Some(d) => d,
        };

        // The keyname is passed in by the caller.
        // It simply is the first query parameter in the list.
        let (keyname, keyval) = match keyname {
            Some(k) => match query.get(k) {
                Some(v) => (k, v),
                None => return Err(json_error(StatusCode::BAD_REQUEST, None, "query params garbled")),
            },
            None => return Err(json_error(StatusCode::BAD_REQUEST, None, "query params missing")),
        };

        // find the map
        debug!("webnis.handle_map: domain [{}] map [{}] keyname [{}]", domain.name, map, keyname);
        let (map, keyname) = match self.inner.config.find_allowed_map(&domain, map, keyname) {
            None => return Err(json_error(StatusCode::NOT_FOUND, None, "No such map/keyname combo")),
            Some(m) => m,
        };

        let res = match map.map_type {
            MapType::Gdbm => self.lookup_gdbm_map(domain, map, keyval),
            MapType::Json => self.lookup_json_map(domain, map, keyname, keyval),
            MapType::Lua => self.lookup_lua_map(domain, map, keyname, keyval),
            MapType::None => unreachable!(),
        };
        match res {
            Err(WnError::KeyNotFound) => Err(json_error(StatusCode::NOT_FOUND, None, "No such key in map")),
            Err(WnError::MapNotFound) => Err(json_error(StatusCode::NOT_FOUND, None, "No such map")),
            Err(WnError::UnknownFormat) => Err(json_error(StatusCode::NOT_FOUND, None, "Unknown map format")),
            Err(WnError::SerializeJson(_)) => Err(json_error(StatusCode::NOT_FOUND, None, "Serialize error")),
            Err(_) => Err(json_error(StatusCode::INTERNAL_SERVER_ERROR, None, "Error reading database")),
            Ok(r) => json_result(StatusCode::OK, &r),
        }
    }
// look something up in a map.
look something up in a map.
look something up in a map .
pub fn handle_map(&self, domain: &str, map: &str, keyname: Option<&str>, query: &HashMap<String, String>) -> WarpResult {
        // lookup domain in config
        let domain = match self.inner.config.find_domain(&domain) {
            None => return Err(json_error(StatusCode::BAD_REQUEST, None, "Domain not found")),
            Some(d) => d,
        };
        // The keyname is passed in by the caller.
        // It simply is the first query parameter in the list.
        let (keyname, keyval) = match keyname {
            Some(k) => match query.get(k) {
                Some(v) => (k, v),
                None => return Err(json_error(StatusCode::BAD_REQUEST, None, "query params garbled")),
            },
            None => return Err(json_error(StatusCode::BAD_REQUEST, None, "query params missing")),
        };
        // find the map
        debug!("webnis.handle_map: domain [{}] map [{}] keyname [{}]", domain.name, map, keyname);
        let (map, keyname) = match self.inner.config.find_allowed_map(&domain, map, keyname) {
            None => return Err(json_error(StatusCode::NOT_FOUND, None, "No such map/keyname combo")),
            Some(m) => m,
        };
        let res = match map.map_type {
            MapType::Gdbm => self.lookup_gdbm_map(domain, map, keyval),
            MapType::Json => self.lookup_json_map(domain, map, keyname, keyval),
            MapType::Lua => self.lookup_lua_map(domain, map, keyname, keyval),
            MapType::None => unreachable!(),
        };
        match res {
            Err(WnError::KeyNotFound) => Err(json_error(StatusCode::NOT_FOUND, None, "No such key in map")),
            Err(WnError::MapNotFound) => Err(json_error(StatusCode::NOT_FOUND, None, "No such map")),
            Err(WnError::UnknownFormat) => Err(json_error(StatusCode::NOT_FOUND, None, "Unknown map format")),
            Err(WnError::SerializeJson(_)) => Err(json_error(StatusCode::NOT_FOUND, None, "Serialize error")),
            Err(_) => Err(json_error(StatusCode::INTERNAL_SERVER_ERROR, None, "Error reading database")),
            Ok(r) => json_result(StatusCode::OK, &r),
        }
    }
pub fn handle_map ( & self , domain : & str , map : & str , keyname : Option < & str > , query : & HashMap < String , String > ) -> WarpResult { // lookup domain in config let domain = match self . inner . config . find_domain ( & domain ) { None => return Err ( json_error ( StatusCode :: BAD_REQUEST , None , " " ) ) , Some ( d ) => d , } ; // The keyname is passed in by the caller. // It simply is the first query parameter in the list. let ( keyname , keyval ) = match keyname { Some ( k ) => match query . get ( k ) { Some ( v ) => ( k , v ) , None => return Err ( json_error ( StatusCode :: BAD_REQUEST , None , " " ) ) , } , None => return Err ( json_error ( StatusCode :: BAD_REQUEST , None , " " ) ) , } ; // find the map debug ! ( " " domain name map keyname ) ; let ( map , keyname ) = match self . inner . config . find_allowed_map ( & domain , map , keyname ) { None => return Err ( json_error ( StatusCode :: NOT_FOUND , None , " " ) ) , Some ( m ) => m , } ; let res = match map . map_type { MapType :: Gdbm => self . lookup_gdbm_map ( domain , map , keyval ) , MapType :: Json => self . lookup_json_map ( domain , map , keyname , keyval ) , MapType :: Lua => self . lookup_lua_map ( domain , map , keyname , keyval ) , MapType :: None => unreachable ! ( ) , } ; match res { Err ( WnError :: KeyNotFound ) => Err ( json_error ( StatusCode :: NOT_FOUND , None , " " ) ) , Err ( WnError :: MapNotFound ) => Err ( json_error ( StatusCode :: NOT_FOUND , None , " " ) ) , Err ( WnError :: UnknownFormat ) => Err ( json_error ( StatusCode :: NOT_FOUND , None , " " ) ) , Err ( WnError :: SerializeJson ( _ ) ) => Err ( json_error ( StatusCode :: NOT_FOUND , None , " " ) ) , Err ( _ ) => Err ( json_error ( StatusCode :: INTERNAL_SERVER_ERROR , None , " " ) ) , Ok ( r ) => json_result ( StatusCode :: OK , & r ) , } }
look something up in a map.
look something up in a map .
&self
domain
&str
map
&str
keyname
Option<&str>
query
&HashMap<String, String>