Yesod 没有路由到处理程序
Yesod not routing to handler
我正在使用堆栈工具构建一个脚手架 yesod (yesod 1.4.1.5
) 应用程序。我找不到新的上班路线。
# config/routes
/static StaticR Static appStatic
/auth AuthR Auth getAuth
/favicon.ico FaviconR GET
/robots.txt RobotsR GET
/trails TrailsR GET
/ HomeR GET POST
然后我定义了以下模块:
-- 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")
我制作了步道模板文件:
-- templates/trails.hamlet
<h1>All Trails A-Z
<ul>
<li>Hi
我没有创建 .julius
或 .lucius
文件。这重要吗?
并且我确保将模块放入 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
并且我确保在项目的 onh.cabal
中注册该模块,这是完整的库节:
library
hs-source-dirs: ., app
exposed-modules: Application
Foundation
Import
Import.NoFoundation
Model
Settings
Settings.StaticFiles
Handler.Common
Handler.Home
Handler.Trails
然后我这样启动应用程序:stack exec -- yesod devel
但它仍然没有返回 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
我做错了什么?我如何调试路由是否正确连接并连接到构建系统?
您可能受到错误影响 described on the mailing list。升级到 yesod-bin-1.4.14 应该可以解决这个问题。你能试试看它是否有效吗?
我正在使用堆栈工具构建一个脚手架 yesod (yesod 1.4.1.5
) 应用程序。我找不到新的上班路线。
# config/routes
/static StaticR Static appStatic
/auth AuthR Auth getAuth
/favicon.ico FaviconR GET
/robots.txt RobotsR GET
/trails TrailsR GET
/ HomeR GET POST
然后我定义了以下模块:
-- 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")
我制作了步道模板文件:
-- templates/trails.hamlet
<h1>All Trails A-Z
<ul>
<li>Hi
我没有创建 .julius
或 .lucius
文件。这重要吗?
并且我确保将模块放入 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
并且我确保在项目的 onh.cabal
中注册该模块,这是完整的库节:
library
hs-source-dirs: ., app
exposed-modules: Application
Foundation
Import
Import.NoFoundation
Model
Settings
Settings.StaticFiles
Handler.Common
Handler.Home
Handler.Trails
然后我这样启动应用程序:stack exec -- yesod devel
但它仍然没有返回 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
我做错了什么?我如何调试路由是否正确连接并连接到构建系统?
您可能受到错误影响 described on the mailing list。升级到 yesod-bin-1.4.14 应该可以解决这个问题。你能试试看它是否有效吗?