@@ -16,6 +16,7 @@ module Obelisk.Backend
1616 , serveDefaultObeliskApp
1717 , prettifyOutput
1818 , runBackend
19+ , staticRenderContentType
1920 ) where
2021
2122import Prelude hiding (id, (.))
@@ -38,8 +39,8 @@ import Obelisk.ExecutableConfig.Inject (injectExecutableConfigs)
3839import Obelisk.Frontend
3940import Obelisk.Route
4041import Reflex.Dom
41−import Snap (MonadSnap, Snap, commandLineConfig, defaultConfig, getsRequest, httpServe, rqPathInfo,
42− rqQueryString, writeBS, writeText)
42+import Snap (MonadSnap, Snap, commandLineConfig, defaultConfig, getsRequest, httpServe, modifyResponse
43+ , rqPathInfo, rqQueryString, setContentType, writeBS, writeText)
4344import Snap.Internal.Http.Server.Config (Config (accessLog, errorLog), ConfigLog (ConfigIoLog))
4445import System.IO (BufferMode (..), hSetBuffering, stderr, stdout)
4546
@@ -132,10 +133,14 @@ data GhcjsAppRoute :: (* -> *) -> * -> * where
132133 GhcjsAppRoute_App :: appRouteComponent a -> GhcjsAppRoute appRouteComponent a
133134 GhcjsAppRoute_Resource :: GhcjsAppRoute appRouteComponent [Text]
134135
136+staticRenderContentType :: ByteString
137+staticRenderContentType = "text/html; charset=utf-8"
138+
135139--TODO: Don't assume we're being served at "/"
136140serveGhcjsApp :: MonadSnap m => GhcjsApp (R appRouteComponent) -> R (GhcjsAppRoute appRouteComponent) -> m ()
137141serveGhcjsApp app = \case
138− GhcjsAppRoute_App appRouteComponent :=> Identity appRouteRest ->
142+ GhcjsAppRoute_App appRouteComponent :=> Identity appRouteRest -> do
143+ modifyResponse $ setContentType staticRenderContentType
139144 writeBS <=< liftIO $ renderGhcjsFrontend (appRouteComponent :/ appRouteRest) $ _ghcjsApp_value app
140145 GhcjsAppRoute_Resource :=> Identity pathSegments -> serveStaticAssets (_ghcjsApp_compiled app) pathSegments
141146