路线与资源

Route vs. Resource

在 Yesod 书中,它在第 I 部分的状态。基础知识,第 3 章。基础知识,Section Routing(第二版):

mkYesod "HelloWorld" [parseRoutes|
/ HomeR GET
|]

In other words, the preceding code simply creates a route [...] called HomeR. [...]. We call HomeR a resource, which is where the R suffix comes from.

这只是措辞问题,我知道,但我想了解 HomeRroute 还是 resource. (请不要说 "both")。

我的理解是基于 this Yesod documentation page

路线/ HomeR GET

组成
  1. 资源模式/
  2. 资源名称HomeR
  3. GET 处理程序

据我所知,每个路由的资源名称都是唯一的,因此文档采用了将 "the route with resource name X" 引用为 "the route X" 的快捷方式。

所以答案是:HomeR是资源,HomeR是资源名称为HomeR的路由。 (换句话说,两者)。