X-Git-Url: https://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FResource.hs;h=d0d9c4866d06665732ab91344ed96dc87dc2ac2a;hb=f57c5c5ae6c95e68b11400718e7ce5de4ea1317a;hp=26d73897e544cc1ec13d3553913bff5bf214da15;hpb=443af4d3304139bb2187a0c726327b9c05829810;p=Rakka.git diff --git a/Rakka/Resource.hs b/Rakka/Resource.hs index 26d7389..d0d9c48 100644 --- a/Rakka/Resource.hs +++ b/Rakka/Resource.hs @@ -3,6 +3,7 @@ module Rakka.Resource , runXmlA , getEntityType , outputXmlPage + , outputXmlPage' , getUserID ) where @@ -127,18 +128,18 @@ getEntityType where extMap :: [(String, MIMEType)] extMap = [ ("html", read "application/xhtml+xml") + , ( "rdf", read "application/rss+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 @@ -150,6 +151,11 @@ outputXmlPage tree toXHTML 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