6

I'm just starting out in Haskell and Yesod. To get my feet wet, I'm going to convert a small project that I wrote in MVC into Haskell. My first step was just to get all the routes defined.

All told, I have 8 handlers to make this project run. My routes file looks like this:

/activity ActivityR GET
/activity/#String ActivityItemR POST DELETE

/dashboard/month MonthDashboardR GET
/dashboard/year YearDashboardR GET

/calendar CalendarR GET

/events/calendar CalendarEventsR GET
/events/report ReportEventsR GET

/report ReportR GET

The flow I went through in adding these routes went like this:

  1. Add route to config/routes
  2. Create file in Handler folder (I created one for each route parent, e.g. /events or /dashboard)
  3. Add an import to the handler created in step #2 to Application.hs
  4. Add the handler file name to my project's cabal file

Is there a shortcut, or way to wildcard these handlers so that I could do something like Import Handler.*

Or is the preferred way to have fewer handler modules that handle multiple different routes?

4

1 回答 1

7

yesod命令行工具提供了add-handler可以自动执行大部分操作的命令。

于 2013-07-01T08:31:36.273 回答