From 484565a5d3d66f730d7d8ebaad8c59e006186e96 Mon Sep 17 00:00:00 2001 From: StellarisW Date: Mon, 4 Nov 2024 10:49:12 +0800 Subject: [PATCH] docs: fix volo http fallback (#1164) --- content/en/docs/volo/volo-http/tutorials/route.md | 9 ++++++--- content/zh/docs/volo/volo-http/tutorials/route.md | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/content/en/docs/volo/volo-http/tutorials/route.md b/content/en/docs/volo/volo-http/tutorials/route.md index 54fcd405aa..a40bd62255 100644 --- a/content/en/docs/volo/volo-http/tutorials/route.md +++ b/content/en/docs/volo/volo-http/tutorials/route.md @@ -279,11 +279,14 @@ async fn router() -> Router { ## Fallback -Volo-HTTP provides a fallback function to handle request url or method mismatches. +Volo-HTTP provides a fallback function to handle request url or method mismatches, **default fallback** will return status code `404 Not Found`. -### url +**Note**: +- Since there is no way to determine which **router fallback** to override in a route in a call to the `merge` method, only one **router fallback** can be set, or else a **panic** will be generated in the call to the `merge` method; + +- The `nest` method is called without overriding the `fallback`. -> Note: Only one **router fallback** can be set globally, otherwise it will generate a **panic** when the `merge` method is called. +### url **Example**: diff --git a/content/zh/docs/volo/volo-http/tutorials/route.md b/content/zh/docs/volo/volo-http/tutorials/route.md index 10e5a09020..6fada2ca79 100644 --- a/content/zh/docs/volo/volo-http/tutorials/route.md +++ b/content/zh/docs/volo/volo-http/tutorials/route.md @@ -275,11 +275,14 @@ async fn router() -> Router { ## fallback -Volo-HTTP 提供了 fallback 功能用于处理请求 url 或 method 不匹配的情况 +Volo-HTTP 提供了 fallback 功能用于处理请求 url 或 method 不匹配的情况,**默认 fallback** 会返回状态码 `404 Not Found`。 -### url +**注意**: +- 调用 `merge` 方法中的路由中由于不能确定覆盖哪一个 **router fallback**, 因此只能设置一个 **router fallback**,否则会在调用 `merge` 方法时产生 **panic**; + +- 调用 `nest` 方法时不会对 `fallback` 进行覆盖。 -> 注意:全局只能设置一个 **router fallback**,否则会在调用 `merge` 方法时产生 **panic** +### url **代码示例**: