在 Yesod 脚手架项目中,我添加了一个新的路由和一个新的处理程序。
我的错误如下:
29/Mar/2017:11:25:22 +0200 [Error#yesod-core] Foundation.hs:(137,5)-(144,45): Non-exhaustive patterns in function isAuthorized
@(yesod-core-1.4.32-6HthMZNCl0sEMRz6GJ4QO1:Yesod.Core.Class.Yesod ./Yesod/Core/Class/Yesod.hs:693:5)
29/Mar/2017:11:25:22 +0200 [Debug#SQL] SELECT `ident`,`password` FROM `user` WHERE `id`=? ; [PersistInt64 1]
我该如何解决?
最佳答案
需要修改Foundation.hs文件,增加新的授权路由:
-- Routes not requiring authentication.
isAuthorized (AuthR _) _ = return Authorized
isAuthorized CommentR _ = return Authorized
isAuthorized HomeR _ = return Authorized
isAuthorized FaviconR _ = return Authorized
isAuthorized RobotsR _ = return Authorized
isAuthorized (StaticR _) _ = return Authorized
isAuthorized TestR _ = return Authorized
isAuthorized ProfileR _ = isAuthenticated
关于haskell - Yesod:函数中的非穷尽模式 isAuthorized,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/43090033/