Search code examples
haskellrouteshaskell-snap-framework

Snap framework root ("/") route not being handed?


I have added routes to my app in the following format:

addRoutes 
  [ ("/",     redirect "/docs/home")
  , ... more routes
  ]

But for some reason the root handler is being ignored altogether. What is happening here?


Solution

  • It turns out that if you have an index.tpl file then the SnapFramework will ignore any "/" mappings and go straight to that instead. To fix the problem I just ran:

    git rm snaplets/heist/templates/index.tpl
    

    And then reloaded my templates and the route on root started working.

    (I could not find that anywhere in the docs so I decided to post that here)

    Edit: I later discovered (with help) that the problem was that I was adding my routes AFTER I ran heistInit. If i added my routes before heistInit then there was no problem.