【发布时间】:2013-07-31 03:08:35
【问题描述】:
在
How to make nicEditor snaplet? (Several questions)
我按照提示将addRoutes 放入snaplet 初始化程序中,它起作用了。将 snap 和 heist (0.12) 模块更新为更新后,我在使用 addRoutes 时遇到了一些困难。如果将addRoutes从nicsnapInit(在snaplet示例中)中删除并放入Application.hs中的routes-function,则该路由与App中的其他路由同时初始化并找到路由。
但是,如果addRoutes 在nicsnapInit 中,服务器只会说
no handler accepted "/netext".
这看起来好像没有添加路由。
目前如何在 snaplet 初始化程序中使用addRoutes(抢劫 0.12)?
几乎马上就知道Snap Framework: Custom snaplet handler won't render template 有几乎类似的问题。在addRoutes 之前使用了addTemplates。经过类似的更改后,这似乎可行,也就是说,使用
addTemplates h ""
其中 h 是 at 的参数
nicsnapInit :: HasHeist b => Snaplet (Heist b) -> SnapletInit b Nicsnap
以及对应用程序初始化程序的相应更改。
这会将 url 更改为“niced/netext”,即首先是 snaplet 名称,然后是 snaplet 中定义的路由。
是否可以只添加“/netext”部分?
【问题讨论】: