parent
ff5618bd15
commit
ba2593c15f
@ -1,3 +1,7 @@
|
|||||||
|
## 1.6.3
|
||||||
|
|
||||||
|
* Add a type `JSONResponse a` that can be used to type a Handler as returning some value `a`, which should be encoded as JSON. [#1481](https://github.com/yesodweb/yesod/issues/1481)
|
||||||
|
|
||||||
## 1.6.2
|
## 1.6.2
|
||||||
|
|
||||||
* Derive a `Show` instance for `ResourceTree` and `FlatResource` [#1492](https://github.com/yesodweb/yesod/pull/1492)
|
* Derive a `Show` instance for `ResourceTree` and `FlatResource` [#1492](https://github.com/yesodweb/yesod/pull/1492)
|
||||||
|
|||||||
@ -251,6 +251,12 @@ instance HasContentType J.Value where
|
|||||||
instance HasContentType J.Encoding where
|
instance HasContentType J.Encoding where
|
||||||
getContentType _ = typeJson
|
getContentType _ = typeJson
|
||||||
|
|
||||||
|
instance ToContent (JSONResponse a) where
|
||||||
|
toContent (JSONResponse a) = toContent $ toEncoding a
|
||||||
|
|
||||||
|
instance HasContentType (JSONResponse a) where
|
||||||
|
getContentType _ = typeJson
|
||||||
|
|
||||||
instance HasContentType Html where
|
instance HasContentType Html where
|
||||||
getContentType _ = typeHtml
|
getContentType _ = typeHtml
|
||||||
|
|
||||||
@ -288,6 +294,8 @@ instance ToTypedContent J.Value where
|
|||||||
toTypedContent v = TypedContent typeJson (toContent v)
|
toTypedContent v = TypedContent typeJson (toContent v)
|
||||||
instance ToTypedContent J.Encoding where
|
instance ToTypedContent J.Encoding where
|
||||||
toTypedContent e = TypedContent typeJson (toContent e)
|
toTypedContent e = TypedContent typeJson (toContent e)
|
||||||
|
instance ToTypedContent (JSONResponse a) where
|
||||||
|
toTypedContent c = TypedContent typeJson (toContent c)
|
||||||
instance ToTypedContent Html where
|
instance ToTypedContent Html where
|
||||||
toTypedContent h = TypedContent typeHtml (toContent h)
|
toTypedContent h = TypedContent typeHtml (toContent h)
|
||||||
instance ToTypedContent T.Text where
|
instance ToTypedContent T.Text where
|
||||||
|
|||||||
@ -308,6 +308,18 @@ newtype RepXml = RepXml Content
|
|||||||
|
|
||||||
type ContentType = ByteString -- FIXME Text?
|
type ContentType = ByteString -- FIXME Text?
|
||||||
|
|
||||||
|
-- | Wrapper around types so that Handlers can be typed them, encoded as JSON.
|
||||||
|
-- Example usage in a type signature:
|
||||||
|
--
|
||||||
|
-- > postSignupR :: Handler (JSONResponse CreateUserResponse)
|
||||||
|
--
|
||||||
|
-- And in the implementation:
|
||||||
|
--
|
||||||
|
-- > return $ JSONResponse $ CreateUserResponse userId
|
||||||
|
--
|
||||||
|
-- @since 1.6.3
|
||||||
|
data JSONResponse a = ToJSON a => JSONResponse a
|
||||||
|
|
||||||
-- | Prevents a response body from being fully evaluated before sending the
|
-- | Prevents a response body from being fully evaluated before sending the
|
||||||
-- request.
|
-- request.
|
||||||
--
|
--
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
name: yesod-core
|
name: yesod-core
|
||||||
version: 1.6.2
|
version: 1.6.3
|
||||||
license: MIT
|
license: MIT
|
||||||
license-file: LICENSE
|
license-file: LICENSE
|
||||||
author: Michael Snoyman <michael@snoyman.com>
|
author: Michael Snoyman <michael@snoyman.com>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user