Skip to content

Commit

Permalink
Added toJSON instance for ID' and added charset to Content-Type
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasrueb committed Aug 10, 2020
1 parent ac0e693 commit e53d674
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion IHP/Controller/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ renderPlain text = respondAndExit $ responseLBS status200 [(hContentType, "text/

{-# INLINE respondHtml #-}
respondHtml :: (?requestContext :: RequestContext) => Html -> IO ()
respondHtml html = respondAndExit $ responseBuilder status200 [(hContentType, "text/html"), (hConnection, "keep-alive")] (Blaze.renderHtmlBuilder html)
respondHtml html = respondAndExit $ responseBuilder status200 [(hContentType, "text/html; charset=utf-8"), (hConnection, "keep-alive")] (Blaze.renderHtmlBuilder html)

{-# INLINE respondSvg #-}
respondSvg :: (?requestContext :: RequestContext) => Html -> IO ()
Expand Down
4 changes: 4 additions & 0 deletions IHP/ModelSupport.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import qualified Control.Newtype.Generics as Newtype
import Control.Applicative (Const)
import qualified GHC.Types as Type
import qualified Data.Text as Text
import Data.Aeson (ToJSON (..))

data ModelContext = ModelContext { databaseConnection :: Connection }

Expand Down Expand Up @@ -425,3 +426,6 @@ fieldWithUpdate name model
| cs (symbolVal name) `elem` get #touchedFields (get #meta model) =
Update (get name model)
| otherwise = NoUpdate name

instance (ToJSON (PrimaryKey a)) => ToJSON (Id' a) where
toJSON (Id a) = toJSON a

0 comments on commit e53d674

Please sign in to comment.