Search code examples
haskellcabalyesodhaskell-stack

Yesod not routing to handler


I am with a scaffolded yesod (yesod 1.4.1.5) application using the stack tool. I cannot get a new route to work.

# config/routes
/static StaticR Static appStatic
/auth   AuthR   Auth   getAuth

/favicon.ico FaviconR GET
/robots.txt RobotsR GET

/trails TrailsR  GET

/ HomeR          GET POST

Then I defined the following module:

-- Handler/Trails.hs
module Handler.Trails where

import Import
--import Yesod.Form.Bootstrap3 (BootstrapFormLayout (..), renderBootstrap3,
--                              withSmallInput)

getTrailsR :: Handler Html
getTrailsR = defaultLayout $ do
    setTitle "Welcome To Yesod!"
    $(widgetFile "trails")

I made the trails template file:

-- templates/trails.hamlet
<h1>All Trails A-Z

<ul>
  <li>Hi

I did not create the .julius or .lucius files. Does that matter?

And I made sure to put the module in Application.hs:

-- Import all relevant handler modules here.
-- Don't forget to add new modules to your cabal file!
import Handler.Common
import Handler.Home
import Handler.Trails

And I made sure to register that module in the onh.cabal for the project, here's the full library stanza:

library
    hs-source-dirs: ., app
    exposed-modules: Application
                     Foundation
                     Import
                     Import.NoFoundation
                     Model
                     Settings
                     Settings.StaticFiles
                     Handler.Common
                     Handler.Home
                     Handler.Trails

Then I boot the app as such: stack exec -- yesod devel but it still doesn't comes back as a 404:

$ curl -v localhost:3000/trails
* Hostname was NOT found in DNS cache
*   Trying ::1...
* connect to ::1 port 3000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /trails HTTP/1.1
> User-Agent: curl/7.37.1
> Host: localhost:3000
> Accept: */*
>
< HTTP/1.1 404 Not Found
< Transfer-Encoding: chunked
< Date: Mon, 31 Aug 2015 05:00:17 GMT
* Server Warp/3.1.2 is not blacklisted
< Server: Warp/3.1.2

What am I doing wrong? How can I debug that routes are wired up correctly and hooked in to the build system?


Solution

  • You may be affected by a bug described on the mailing list. Upgrading to yesod-bin-1.4.14 should fix that issue. Can you try that and see if it works?