我對Haskell非常陌生,因爲您可以猜測Yesod也是新手。我想玩弄這兩種方法,以更多地瞭解Haskell和Web開發。Yesod:無法在另一個處理程序中訪問LoginR
我有兩個問題,他們都可能是由於我缺乏的Haskell知識愚蠢的錯誤,我做:
(1)我創建了SQLite的腳手架網站(我用耶索德1.2)。我試圖在生成的homepage.hamlet文件中添加一行,它給了我一個錯誤(順便說一句,該網站工作正常,沒有這個補充)。我加了一行是:
<a [email protected]{AuthR LoginR}>Go to the login page
後,我收到此錯誤信息:
Handler/Home.hs:34:11:
Not in scope: data constructor `LoginR'
In the result of the splice:
$(widgetFile "homepage")
To see what the splice expanded to, use -ddump-splices
In a stmt of a 'do' block: $(widgetFile "homepage")
In the second argument of `($)', namely
`do { aDomId <- newIdent;
setTitle "Welcome To Yesod!";
$(widgetFile "homepage") }'
有沒有辦法在其他處理程序/模板暴露LoginR? (2)我最終想定製登錄頁面的外觀和感覺,所以我試圖按照這裏的說明(也認爲這可能會解決上述問題,因爲我聲明自己的處理程序在範圍內):http://hackological.com/blog/using-twitter-to-authenticate-in-yesod/。基本上我修改Foundation.hs的authRoute聲明如下
authRoute _ = Just LoginPanelR
,然後加入航線:
/login LoginPanelR GET
和Home.hs
getLoginPanelR :: Handler RepHtml
getLoginPanelR = defaultLayout $(widgetFile "login")
添加了處理程序我也創建了相應的包含鏈接中提供的內容的login.hamlet文件。然後我得到以下錯誤:
Foundation.hs:100:32:
Couldn't match type `App' with `Auth'
Expected type: Route Auth
Actual type: Route App
In the first argument of `AuthR', namely `LoginPanelR'
In the second argument of `($)', namely `AuthR LoginPanelR'
In the expression: Just $ AuthR LoginPanelR
請問我是否知道我做錯了什麼?
謝謝!
非常感謝!它現在有效。我期待更多地瞭解Yesod。當我絆倒你可能會看到更多的問題:)順便說一句,不知道是否有人向你提到這件事,昨天(6月11日)yesodweb.com斷斷續續 - 無法連接,但使用瀏覽器的服務器是它響應去ping。 – Ecognium