From 9ba6d77e649b3d9dea2c2a79527e85a47536cdbe Mon Sep 17 00:00:00 2001 From: ZzIsGod1019 <1498852723@qq.com> Date: Tue, 9 Apr 2024 17:34:12 +0800 Subject: [PATCH] open-api: modify cache key (#705) --- backend/supports/iam/src/basic/serv/iam_open_serv.rs | 12 ++++++++++-- backend/supports/iam/src/iam_config.rs | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/supports/iam/src/basic/serv/iam_open_serv.rs b/backend/supports/iam/src/basic/serv/iam_open_serv.rs index 09aec2868..20dd3085c 100644 --- a/backend/supports/iam/src/basic/serv/iam_open_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_open_serv.rs @@ -483,8 +483,16 @@ impl IamOpenServ { Ok(IamOpenRuleResp { cert_id, spec_code, - start_time: time_range.split(',').collect_vec().first().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc)), - end_time: time_range.split(',').collect_vec().last().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc)), + start_time: if !time_range.is_empty() { + time_range.split(',').collect_vec().first().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc)) + } else { + None + }, + end_time: if !time_range.is_empty() { + time_range.split(',').collect_vec().last().map(|s| DateTime::parse_from_rfc3339(s).unwrap().with_timezone(&Utc)) + } else { + None + }, api_call_frequency: IamIdentCacheServ::get_gateway_rule_info(&ak, OPENAPI_GATEWAY_PLUGIN_LIMIT, None, funs).await?.map(|s| s.parse::().unwrap_or_default()), api_call_count: IamIdentCacheServ::get_gateway_rule_info(&ak, OPENAPI_GATEWAY_PLUGIN_COUNT, None, funs).await?.map(|s| s.parse::().unwrap_or_default()), api_call_cumulative_count: IamIdentCacheServ::get_gateway_cumulative_count(&ak, None, funs).await?.map(|s| s.parse::().unwrap_or_default()), diff --git a/backend/supports/iam/src/iam_config.rs b/backend/supports/iam/src/iam_config.rs index 9c5e44f95..2c2321847 100644 --- a/backend/supports/iam/src/iam_config.rs +++ b/backend/supports/iam/src/iam_config.rs @@ -177,7 +177,7 @@ impl Default for IamConfig { strict_security_mode: false, crypto_conf: CryptoConf::default(), cache_key_gateway_rule_info_: "sg:plugin:".to_string(), - gateway_openapi_path: "op-api".to_string(), + gateway_openapi_path: "/op-api".to_string(), } } }