diff options
author | nopedial <shafez@ike-2.local> | 2013-10-26 10:57:53 +0200 |
---|---|---|
committer | nopedial <shafez@ike-2.local> | 2013-10-26 10:57:53 +0200 |
commit | 4af4b982307f5abce1c01b3bd39aa1cd03d8b768 (patch) | |
tree | 18611dcb3fe30e29ad5a3250fab36cb768f801a2 /lib/oxidized | |
parent | 5748dc015db423e4469c4bfd43442ba6bea72160 (diff) |
clean ascii API output
Diffstat (limited to 'lib/oxidized')
-rw-r--r-- | lib/oxidized/api/rest.rb | 12 |
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 |