Search code examples
haskellyesod

Route vs. Resource


In the Yesod book it is state at Part I. Basics, Chapter 3. Basics, Section Routing (Second Edition):

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.

This is just about wording, I know, but I would like to understand if HomeR is a route or a resource. (please don't say "both").


Solution

  • My understanding is based off this Yesod documentation page.

    The route / HomeR GET is made up of

    1. the resource pattern /
    2. the resource name HomeR
    3. the GET handler

    As far as I can tell, the resource name is unique to each route, so the documentation takes the shortcut of referring to "the route with resource name X" as "the route X".

    So the answer is: HomeR is a resource, and HomeR is the route with resource name HomeR. (Both, in other words).