summaryrefslogtreecommitdiff
path: root/lib/oxidized/api/rest.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/oxidized/api/rest.rb')
-rw-r--r--lib/oxidized/api/rest.rb20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/oxidized/api/rest.rb b/lib/oxidized/api/rest.rb
index d1bd7dc..cdf5c80 100644
--- a/lib/oxidized/api/rest.rb
+++ b/lib/oxidized/api/rest.rb
@@ -4,11 +4,14 @@ module Oxidized
module API
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
+ def send res, msg='OK', ascii=false, status=200
+ res.body = msg
+ if not ascii
+ msg = {:result => msg}
+ res['Content-Type'] = 'application/json'
+ res.status = status
+ res.body = JSON.dump msg
+ end
end
end
include Oxidized::API::Rest::Helpers
@@ -47,9 +50,12 @@ module Oxidized
if $1.include? '/'
group, node = $1.split("/")[1..2]
else
- group, node = 0, $1
+ group, node = nil, $1
+ end
+ ascii = if node[-4..-1] == '.txt'
+ node = node[0..-5]
end
- send res, @nodes.fetch(node, group)
+ send res, @nodes.fetch(node, group), ascii
rescue Oxidized::NotSupported => e
send res, e
end