diff options
author | nopedial <shafez@ike-2.local> | 2013-10-26 02:14:31 +0200 |
---|---|---|
committer | nopedial <shafez@ike-2.local> | 2013-10-26 02:14:31 +0200 |
commit | 5748dc015db423e4469c4bfd43442ba6bea72160 (patch) | |
tree | 50966057fc833284290b6f81f38e383d925b0b83 | |
parent | 20fb32869cf774d366c1d9a85db05a6f43f8d8f2 (diff) |
add primitive plain ascii API output support
-rw-r--r-- | lib/oxidized/api/rest.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/oxidized/api/rest.rb b/lib/oxidized/api/rest.rb index d1bd7dc..9e7ebb8 100644 --- a/lib/oxidized/api/rest.rb +++ b/lib/oxidized/api/rest.rb @@ -5,10 +5,13 @@ module Oxidized class Rest module Helpers def send res, msg='OK', status=200 - msg = {:result => msg} - res['Content-Type'] = 'application/json' - res.status = status - res.body = JSON.dump msg + res.body = msg + if not res.body[-1] == '+' + msg = {:result => msg} + res['Content-Type'] = 'application/json' + res.status = status + res.body = JSON.dump msg + end end end include Oxidized::API::Rest::Helpers @@ -49,7 +52,12 @@ module Oxidized else group, node = 0, $1 end - send res, @nodes.fetch(node, group) + 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) + end rescue Oxidized::NotSupported => e send res, e end |