]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Resource.hs
Rakka.Resource.Users
[Rakka.git] / Rakka / Resource.hs
index 9f3af22fd6ef2752c0acdece23c4926177427bbc..c207744da2ab0f4b673c8d3cd5e5354faaaf5f02 100644 (file)
@@ -1,9 +1,11 @@
 module Rakka.Resource
     ( runIdempotentA
+    , runIdempotentA'
     , runXmlA
     , getEntityType
     , outputXmlPage
     , outputXmlPage'
+    , outputXml
     , getUserID
     )
     where
@@ -68,6 +70,17 @@ runIdempotentA baseURI a
          rsrc
 
 
+runIdempotentA' :: IOSArrow () (Resource c) -> Resource c
+runIdempotentA' a
+    = do [rsrc] <- liftIO $ runX ( setErrorMsgHandler False fail
+                                   >>>
+                                   constA ()
+                                   >>>
+                                   a
+                                 )
+         rsrc
+
+
 runXmlA :: Environment -> FilePath -> IOSArrow XmlTree (Resource c) -> Resource c
 runXmlA env schemaPath a
     = do inputA <- getInputXmlA env schemaPath
@@ -159,6 +172,18 @@ outputXmlPage' tree toXHTML
     = outputXmlPage tree [(MIMEType "application" "xhtml+xml" [], toXHTML)]
 
 
+outputXml :: XmlTree -> Resource ()
+outputXml tree
+    = do setContentType (MIMEType "text" "xml" [])
+         [xmlStr] <- liftIO $ runX ( setErrorMsgHandler False fail
+                                    >>>
+                                    constA tree
+                                    >>>
+                                    writeDocumentToString [ (a_indent, v_1) ]
+                                  )
+        output xmlStr
+
+
 getUserID :: Environment -> Resource (Maybe String)
 getUserID env
     = do auth <- getAuthorization