@finesoft/front 0.1.77 → 0.1.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -191,6 +191,12 @@ const match = framework.router.resolve("/products/42");
|
|
|
191
191
|
|
|
192
192
|
`router.resolve()` returns `null` for unmatched URLs — handle this in your server-side 404 logic.
|
|
193
193
|
|
|
194
|
+
## Try it
|
|
195
|
+
|
|
196
|
+
A live `Router` instance is registered with the sample routes below. Type a URL on the left and watch `Router.resolve()` produce a `RouteMatch` on the right — the same code path the framework uses at runtime.
|
|
197
|
+
|
|
198
|
+
<Ch02RouteResolver />
|
|
199
|
+
|
|
194
200
|
## Next
|
|
195
201
|
|
|
196
202
|
- [Middleware](./03-middleware.md) — gating navigation, redirects, denies
|
package/docs/03-middleware.md
CHANGED
|
@@ -208,6 +208,12 @@ async function rateLimitGuard(ctx: NavigationContext) {
|
|
|
208
208
|
- **`deny()` in `afterLoad` discards the produced page.** The controller already ran; deny only blocks the response. If `execute()` had side effects (writes), they already happened.
|
|
209
209
|
- **Browser-side guards do not have access to request headers.** `getHeader()` returns `null` on the client. Cookies still work.
|
|
210
210
|
|
|
211
|
+
## Try it
|
|
212
|
+
|
|
213
|
+
Build a `beforeLoad` chain of three guards, pick the result each one returns, then run it through the **real** `runBeforeLoadGuards()` from `@finesoft/core`. The pipeline below shows where the chain short-circuits and what the final `MiddlewareResult` looks like.
|
|
214
|
+
|
|
215
|
+
<Ch03MiddlewarePlayground />
|
|
216
|
+
|
|
211
217
|
## Next
|
|
212
218
|
|
|
213
219
|
- [Rendering & hydration](./04-rendering-and-hydration.md) — what happens between `afterLoad` and HTML output
|
|
@@ -191,6 +191,12 @@ const match = framework.router.resolve("/products/42");
|
|
|
191
191
|
|
|
192
192
|
未命中返回 `null` —— 在服务端 404 逻辑里处理它。
|
|
193
193
|
|
|
194
|
+
## 实时演示
|
|
195
|
+
|
|
196
|
+
下方注册了一个真实的 `Router` 实例(包含示例路由)。在左侧输入 URL,右侧实时显示 `Router.resolve()` 的 `RouteMatch` —— 与框架运行时走的是同一段代码。
|
|
197
|
+
|
|
198
|
+
<Ch02RouteResolver />
|
|
199
|
+
|
|
194
200
|
## 下一步
|
|
195
201
|
|
|
196
202
|
- [中间件](./03-middleware.md) —— 守卫导航、重定向、拒绝
|
package/docs/zh/03-middleware.md
CHANGED
|
@@ -208,6 +208,12 @@ async function rateLimitGuard(ctx: NavigationContext) {
|
|
|
208
208
|
- **`afterLoad` 里的 `deny()` 会丢弃已产出的页面。** Controller 已经跑过了;deny 只阻断响应。如果 `execute()` 有副作用(写操作),副作用已经发生。
|
|
209
209
|
- **浏览器端守卫拿不到请求头。** `getHeader()` 在客户端返回 `null`。cookie 仍然可用。
|
|
210
210
|
|
|
211
|
+
## 实时演示
|
|
212
|
+
|
|
213
|
+
构造一条三守卫的 `beforeLoad` 链,逐个选定每个 guard 的返回值,然后交给 `@finesoft/core` 里**真实**的 `runBeforeLoadGuards()` 跑一次。下方流水线会显示链路在哪一步短路、最终的 `MiddlewareResult` 是什么。
|
|
214
|
+
|
|
215
|
+
<Ch03MiddlewarePlayground />
|
|
216
|
+
|
|
211
217
|
## 下一步
|
|
212
218
|
|
|
213
219
|
- [渲染与 Hydration](./04-rendering-and-hydration.md) —— `afterLoad` 到 HTML 输出之间发生什么
|