From 4af4b982307f5abce1c01b3bd39aa1cd03d8b768 Mon Sep 17 00:00:00 2001
From: nopedial <shafez@ike-2.local>
Date: Sat, 26 Oct 2013 10:57:53 +0200
Subject: clean ascii API output

---
 lib/oxidized/api/rest.rb | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

(limited to 'lib/oxidized/api')

diff --git a/lib/oxidized/api/rest.rb b/lib/oxidized/api/rest.rb
index 9e7ebb8..f1a7ef5 100644
--- a/lib/oxidized/api/rest.rb
+++ b/lib/oxidized/api/rest.rb
@@ -4,9 +4,9 @@ module Oxidized
   module API
     class Rest
       module Helpers
-        def send res, msg='OK', status=200
+        def send res, json, msg='OK', status=200
           res.body = msg
-          if not res.body[-1] == '+' 
+          if not json
             msg = {:result => msg}
             res['Content-Type'] = 'application/json'
             res.status = status
@@ -52,12 +52,10 @@ module Oxidized
               else
                 group, node = 0, $1
               end
-              if node.include? '.txt'
-                node.gsub! '.txt', ''
-                send res, [ @nodes.fetch(node, group) + '+' ].join(':') # add local switch to trick 'send' out of json formatting
-              else
-                send res, @nodes.fetch(node, group)
+              json = if node[-4..-1] == '.txt'
+                node = node[0..-5]
               end
+              send res, json, @nodes.fetch(node, group)
             rescue Oxidized::NotSupported => e
               send res, e
             end
-- 
cgit v1.2.3