, runXmlA
, getEntityType
, outputXmlPage
+ , outputXmlPage'
, getUserID
)
where
where
extMap :: [(String, MIMEType)]
extMap = [ ("html", read "application/xhtml+xml")
+ , ( "rdf", read "application/rdf+xml" )
, ( "xml", read "text/xml" )
]
-outputXmlPage :: XmlTree -> IOSArrow XmlTree XmlTree -> Resource ()
-outputXmlPage tree toXHTML
+outputXmlPage :: XmlTree -> [(MIMEType, IOSArrow XmlTree XmlTree)] -> Resource ()
+outputXmlPage tree formatters
= do mType <- getEntityType
setContentType mType
- let formatter = case mType of
- MIMEType "application" "xhtml+xml" _ -> toXHTML
- MIMEType "text" "xml" _ -> this
- _ -> undefined
+ let formatter = case lookup mType formatters of
+ Just f -> f
+ Nothing -> this
[resultStr] <- liftIO $ runX ( setErrorMsgHandler False fail
>>>
constA tree
output resultStr
+outputXmlPage' :: XmlTree -> IOSArrow XmlTree XmlTree -> Resource ()
+outputXmlPage' tree toXHTML
+ = outputXmlPage tree [(MIMEType "application" "xhtml+xml" [], toXHTML)]
+
+
getUserID :: Environment -> Resource (Maybe String)
getUserID env
= do auth <- getAuthorization