2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/version_controller.rb', line 2
def index
@versioninfo = VersionHelper::VersionInfo.createVersionInfo()
content_type = Mime::Type.lookup(env['CONTENT_TYPE'])
unless content_type
content_type = Mime::Type.parse(env['HTTP_ACCEPT'])
content_type = content_type.shift if content_type.is_a?(Array)
end
format = if params[:format]
params[:format].gsub(%r'^/*','').to_sym
else
content_type ? content_type.to_sym : :html
end
case format
when :json
render json: @versioninfo.to_h.to_json
when :xml
render xml: @versioninfo.to_h.to_xml
else
render plain: @versioninfo.to_s
end
end
|