By | Chris Done;Chris Done |
At | 2011-06-14; 2011-06-14 |
Title | Default to text/html output type unless specified otherwise. |
Description |
Edit file src/Amelie/Controller.hs 33188 → 33188
23 23 import Data.ByteString.UTF8 (toString)
24 24 import Data.Text.Lazy (Text,toStrict)
25 25 import Database.PostgreSQL.Simple (Pool,withPoolConnection)
26 26 import Safe (readMay)
27 27 import Snap.Types (Snap,writeText,redirect,getParam)
+ 28 import Snap.Types (modifyResponse,setContentType)
28 29 import Text.Blaze (Html)
29 30 import Text.Blaze.Renderer.Text (renderHtml)
30 31 31 32 -- | Run a controller handler.
32 33 runHandler :: Config -> Pool -> Cache -> Chan Text -> Controller () -> Snap ()
33 34 runHandler conf pool cache anns ctrl = do
34 35 withPoolConnection pool $ \conn -> do
35 36 let state = ControllerState conf conn cache anns
+ 37 -- Default to HTML, can be overridden.
+ 38 modifyResponse $ setContentType "text/html"
36 39 runReaderT (runController ctrl) state
37 40 38 41 -- | Strictly renders HTML to Text before outputting it via Snap.
39 42 -- This ensures that any lazy exceptions are caught by the Snap
40 43 -- handler.
… … … …