[Jifty-commit] r2040 - in jifty/trunk: .

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Thu Oct 19 23:00:34 EDT 2006


Author: jesse
Date: Thu Oct 19 23:00:33 2006
New Revision: 2040

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/plugins/REST/lib/Jifty/Plugin/REST/Dispatcher.pm

Log:
 r28963 at pinglin:  jesse | 2006-10-19 22:30:10 -0400
  * first cut at xml ws


Modified: jifty/trunk/plugins/REST/lib/Jifty/Plugin/REST/Dispatcher.pm
==============================================================================
--- jifty/trunk/plugins/REST/lib/Jifty/Plugin/REST/Dispatcher.pm	(original)
+++ jifty/trunk/plugins/REST/lib/Jifty/Plugin/REST/Dispatcher.pm	Thu Oct 19 23:00:33 2006
@@ -9,6 +9,7 @@
 use Jifty::YAML ();
 use Jifty::JSON ();
 use Data::Dumper ();
+use XML::Simple;
 
 before qr{^ (/=/ .*) \. (js|json|yml|yaml|perl|pl) $}x => run {
     $ENV{HTTP_ACCEPT} = $2;
@@ -66,6 +67,12 @@
         $apache->send_http_header;
         print Data::Dumper::Dumper(@_);
     }
+    elsif ($accept =~ /xml/i) {
+        $apache->header_out('Content-Type' => 'text/xml; charset=UTF-8');
+        $apache->send_http_header;
+        print  render_as_xml(@_);
+
+    }
     else {
          
         $apache->header_out('Content-Type' => 'text/html; charset=UTF-8');
@@ -77,6 +84,19 @@
 }
 
 sub render_as_html {
+    my $content = shift;
+    if (ref($content) eq 'ARRAY') {
+        return XMLout({$content});
+    }
+    elsif (ref($content) eq 'HASH') {
+        return XMLout($content);
+    } else {
+        return XMLout({$content})
+    }
+}
+
+
+sub render_as_html {
     my $prefix = shift;
     my $url = shift;
     my $content = shift;


More information about the Jifty-commit mailing list