Skip to content

Commit 1a3ead3

Browse files
fix(core): 修复路由树未注入全局配置导致示例500 (#130)
在 RouteTree::call 开始处将当前节点的 Configs 克隆并写入 req.configs_mut(),确保通过 Request::get_config 能获取到在 Server/Route 上设置的配置。\n\n修复 examples/configs 示例中 get_config 返回 ConfigNotFound 进而触发 500 的问题。\n\n该变更不覆盖既有 None 情况,仅在节点存在配置时注入,兼容现有逻辑。
1 parent f311ed3 commit 1a3ead3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

silent/src/route/route_tree.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ impl RouteTree {
134134
impl Handler for RouteTree {
135135
async fn call(&self, req: Request) -> crate::error::SilentResult<Response> {
136136
let (mut req, last_path) = req.split_url();
137+
if let Some(configs) = self.get_configs().cloned() {
138+
*req.configs_mut() = configs;
139+
}
137140
// 入口处匹配当前结点一次
138141
let (matched, remain) = self.match_current(&mut req, last_path.as_str());
139142
if !matched {

0 commit comments

Comments
 (0)