Skip to content

Instantly share code, notes, and snippets.

@kazu-yamamoto
Created November 15, 2013 06:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazu-yamamoto/7480057 to your computer and use it in GitHub Desktop.
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.
{-# 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