Skip to content

Commit 5bcffc0

Browse files
committed
feat: add unlimited levels of route group and middleware
1 parent e62d519 commit 5bcffc0

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

docs/3.0/zh-cn/mix-vega.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,11 @@ $vega->handle('/hello', function (Mix\Vega\Context $ctx) {
196196

197197
```php
198198
$vega = new Mix\Vega\Engine();
199-
$sub = $vega->pathPrefix('/foo');
200-
$sub->handle('/bar1', function (Mix\Vega\Context $ctx) {
199+
$foo = $vega->pathPrefix('/foo');
200+
$bar = $foo->pathPrefix('/bar');
201+
$bar->handle('/baz', function (Mix\Vega\Context $ctx) { // path=/foo/bar/baz
201202
$ctx->string(200, 'hello, world!');
202203
})->methods('GET');
203-
$sub->handle('/bar2', function (Mix\Vega\Context $ctx) {
204-
$ctx->string(200, 'hello1, world!');
205-
})->methods('GET');
206204
```
207205

208206
## 参数获取
@@ -408,7 +406,9 @@ $vega->handle('/hello', $func, function (Mix\Vega\Context $ctx) {
408406
})->methods('GET');
409407
```
410408

411-
配置全局中间件,即便没有匹配到路由也会执行
409+
配置全局中间件
410+
411+
- 全局中间件:即便没有匹配到路由也会执行
412412

413413
```php
414414
$vega = new Mix\Vega\Engine();
@@ -417,6 +417,16 @@ $vega->use(function (Mix\Vega\Context $ctx) {
417417
});
418418
```
419419

420+
- 路由前缀全局中间件
421+
422+
```php
423+
$vega = new Mix\Vega\Engine();
424+
$foo = $vega->pathPrefix('/foo');
425+
$foo->use(function (Mix\Vega\Context $ctx) {
426+
$ctx->next();
427+
});
428+
```
429+
420430
前置中间件
421431

422432
```php

src/vega/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ $vega->handle('/hello', $func, function (Mix\Vega\Context $ctx) {
419419
})->methods('GET');
420420
```
421421

422-
配置全局中间件,即便没有匹配到路由也会执行
422+
配置全局中间件
423423

424-
- 全局中间件
424+
- 全局中间件:即便没有匹配到路由也会执行
425425

426426
```php
427427
$vega = new Mix\Vega\Engine();

src/vega/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ $vega->handle('/hello', $func, function (Mix\Vega\Context $ctx) {
410410
})->methods('GET');
411411
```
412412

413-
Configure the global middleware, it will be executed even if the route is not matched
413+
Configure the global middleware
414414

415-
- Global middleware
415+
- Global middleware: it will be executed even if the route is not matched
416416

417417
```php
418418
$vega = new Mix\Vega\Engine();

0 commit comments

Comments
 (0)