在
How to make nicEditor snaplet? (Several questions)
我按照提示并将addRoutes
放入snaplet初始化程序中并且它有效。将snap和heist(0.12)模块更新为更新后,我遇到了addRoutes
的一些困难。如果addRoutes
从nicsnapInit
中删除(在snaplet示例中)并放入Application.hs中的routes
- 函数中,则路径将与App和路由中的其他路径同时初始化找到了。
但是,如果addRoutes
位于nicsnapInit
,则服务器只会说
no handler accepted "/netext".
这看起来没有添加路线。
目前如何在snaplet初始值设定项中使用addRoutes
(抢劫0.12)?
几乎立即了解 Snap Framework: Custom snaplet handler won't render template几乎有类似的问题。在addTemplates
之前使用addRoutes
。在进行类似的更改后,这似乎有效,即使用行
addTemplates h ""
其中h是
的参数nicsnapInit :: HasHeist b => Snaplet (Heist b) -> SnapletInit b Nicsnap
并对应用程序初始化程序进行相应的更改。
这会将url更改为“niced / netext”,即首先是snaplet名称,然后是snaplet中定义的路径。
是否可以只添加“/ netext”-part?
答案 0 :(得分:1)
使用nestSnaplet "" nicsnap $ nicsnapInit ...
。 nestSnaplet的第一个参数不是snaplet的名称。它是所有snaplet路由相对的URL。