Created
November 15, 2013 06:28
-
-
Save kazu-yamamoto/7480057 to your computer and use it in GitHub Desktop.
Yesod: returning a static file if path for dynamic contents is wrong. This code set Status to 200.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE OverloadedStrings, QuasiQuotes, TemplateHaskell, TypeFamilies #-} | |
import Yesod | |
import Network.HTTP.Types (status200) | |
data App = App | |
mkYesod "App" [parseRoutes| | |
/home HomeR GET | |
|] | |
instance Yesod App where | |
errorHandler NotFound = sendResponseStatus status200 | |
$ TypedContent typeHtml | |
$ ContentFile "not-found.html" Nothing | |
errorHandler x = defaultErrorHandler x | |
getHomeR :: Handler Html | |
getHomeR = defaultLayout [whamlet|<p>Weird place for a homepage|] | |
main :: IO () | |
main = warpEnv App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment