]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Resource.hs
The experiment has succeeded
[Rakka.git] / Rakka / Resource.hs
index c79b215cfe5fb5e1bce74101982c18ee3cc7922c..ec143733d5173f0645471c03bdbb0a498eb81aef 100644 (file)
@@ -17,11 +17,11 @@ import           Text.XML.HXT.DOM.TypeDefs
 import           Text.XML.HXT.DOM.XmlKeywords
 
 
--- /         ==> /
--- /foo      ==> /foo.html
--- /foo/     ==> /foo.html
--- /foo.bar/ ==> /foo.bar
--- /foo.bar  ==> /foo.bar
+-- "/"         ==> "/"
+-- "/foo"      ==> "/foo.html"
+-- "/foo/"     ==> "/foo.html"
+-- "/foo.bar/" ==> "/foo.bar"
+-- "/foo.bar"  ==> "/foo.bar"
 canonicalizeURI :: Resource ()
 canonicalizeURI 
     = do uri <- getRequestURI
@@ -70,10 +70,9 @@ outputXmlPage :: XmlTree -> IOSArrow XmlTree XmlTree -> Resource ()
 outputXmlPage tree toXHTML
     = do mType <- getEntityType
          setContentType mType
-         let formatter = if mType == read "text/xml" then
-                             this
-                         else
-                             toXHTML
+         let formatter = case mType of
+                           MIMEType "application" "xhtml+xml" _ -> toXHTML
+                           MIMEType "text"        "xml"       _ -> this
          [resultStr] <- liftIO $ runX ( setErrorMsgHandler False fail
                                         >>>
                                         constA tree