From 915d4b72a6d0244dd833cfb4b6a18f0d4bda3655 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E6=B0=B8=E5=B7=9D?= Date: Fri, 26 Jun 2026 13:37:26 +0000 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20docs/doc?= =?UTF-8?q?s/ggs5th.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/docs/ggs5th.md | 53 --------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 docs/docs/ggs5th.md diff --git a/docs/docs/ggs5th.md b/docs/docs/ggs5th.md deleted file mode 100644 index cf14a42..0000000 --- a/docs/docs/ggs5th.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -url: ggs5th ---- - -# 路由编写规范 - - -## 路由闭包 - -
**绝不** 在路由配置文件里书写『闭包路由』或者其他业务逻辑代码 。
-
路由器要保持干净整洁,**绝不** 放置除路由配置以外的其他程序逻辑。
- - -## Restful 路由 - -
**必须** 优先使用 Restful 路由,配合资源控制器使用,见 [文档](http://learnku.com/docs/laravel/5.5/controllers#RESTful-%E8%B5%84%E6%BA%90%E6%8E%A7%E5%88%B6%E5%99%A8)。
-
![](../assets/1600072664191-a563c65e-c263-4757-829b-f78b72118c3d.png)
-
超出 Restful 路由的,**应该** 模仿上图的方式来定义路由。 - -## 单数 or 复数? - -
资源路由路由 URI **必须** 使用复数形式,如:
- -- `/photos/create` -- `/photos/{photo}` - - -
错误的例子如:
- -- `/photo/create` -- `/photo/{photo}` - -## 路由命名 - -
所有路由都 **必须** 使用 `name` 方法进行命名。
-
**必须** 使用『资源前缀』作为命名规范,如下的 `users.follow`,资源前缀的值是 `users.`:
- -```bash -# dingoapi路由写法,和标准lumen有所差异 -$api->post('/users/{id}/follow', ['as' => 'users.follow', 'uses' => 'UsersController@follow']); -``` - - - -## 获取 URL - -
获取 URL **必须** 遵循以下优先级:
- -```bash -app('Dingo\Api\Routing\UrlGenerator')->version('v1')->route('users.index'); -``` - -