summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/oxidized/api/rest.rb12
1 files changed, 5 insertions, 7 deletions
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