servant-xml 1.0.0 → 1.0.1
raw patch · 4 files changed
+29/−7 lines, 4 filesdep +xmlbf-xeno
Dependencies added: xmlbf-xeno
Files
- CHANGELOG.md +9/−0
- README.md +4/−2
- servant-xml.cabal +5/−3
- src/Servant/XML.hs +11/−2
+ CHANGELOG.md view
@@ -0,0 +1,9 @@+# CHANGELOG++### 1.0.1++- Added `MimeUnrender` instance for `XML`.++### 1.0.0++- Initial release.
README.md view
@@ -4,5 +4,7 @@ Types with a `ToXml` instance will be automatically marshalled into XML and successfully returned by Servant endpoints.-In implementing `toXml`, you can use the `element` and `text` primatives-found in the *xmlbf* library.+Types with a `FromXml` instance can be decoded from request bodies.++In implementing these typeclass instances, you can use the primatives+found in the `xmlbf` library.
servant-xml.cabal view
@@ -2,12 +2,12 @@ -- -- see: https://github.com/sol/hpack ----- hash: 75be9f1914f9d92bff857fc253157776eb3d96b62a3fe6f8651a841647e01fbb+-- hash: c8dde3a5e1331b6e0aa8d5e364364b25d4980e50bff936cb8ad9a2b046d896eb name: servant-xml-version: 1.0.0+version: 1.0.1 synopsis: Servant support for the XML Content-Type-description: Servant support for the Content-Type of /application\/xml/. Anything with a 'Xmlbf.ToXml' instance can be automatically marshalled.+description: Servant support for the Content-Type of /application\/xml/. Anything with 'ToXml' and 'FromXml' instances can be automatically marshalled. category: Web homepage: https://github.com/fosskers/servant-xml author: Colin Woodbury@@ -19,6 +19,7 @@ cabal-version: >= 1.10 extra-source-files:+ CHANGELOG.md README.md library@@ -31,6 +32,7 @@ , http-media >=0.7 && <0.8 , servant >=0.11 && <0.13 , xmlbf >=0.3 && <0.4+ , xmlbf-xeno >=0.1 && <0.2 exposed-modules: Servant.XML default-language: Haskell2010
src/Servant/XML.hs view
@@ -11,15 +11,19 @@ -- -- Types with a `ToXml` instance will be automatically marshalled into XML -- and successfully returned by Servant endpoints.--- In implementing `toXml`, you can use the `element` and `text` primatives+-- Types with a `FromXml` instance can be decoded from request bodies.+--+-- In implementing these typeclass instances, you can use the primatives -- found in the /xmlbf/ library. module Servant.XML where import Data.ByteString.Builder (toLazyByteString)+import Data.ByteString.Lazy (toStrict) import qualified Network.HTTP.Media as M import Servant.API import Xmlbf+import Xmlbf.Xeno --- @@ -31,7 +35,9 @@ -- instance ToXml Foo where -- toXml foo = ... ----- type API = ... :\<|\> "foo" :> Get '[XML] Foo+-- type API = ...+-- :\<|\> "foo" :> Get '[XML] Foo+-- :\<|\> "foo" :> "update" :> ReqBody '[XML] Foo :> PostAccepted '[JSON] () -- @ data XML @@ -40,3 +46,6 @@ instance ToXml a => MimeRender XML a where mimeRender _ = toLazyByteString . encode . toXml++instance FromXml a => MimeUnrender XML a where+ mimeUnrender _ bs = nodes (toStrict bs) >>= runParser fromXml