summaryrefslogtreecommitdiff
path: root/report/report_application.rb
diff options
context:
space:
mode:
authorMartin Gütlein <martin.guetlein@gmail.com>2009-11-25 12:40:12 +0100
committerMartin Gütlein <martin.guetlein@gmail.com>2009-11-25 12:40:12 +0100
commit4e76efe724aa723e1f79fb09d4e908323720f1de (patch)
tree864bd7f58eaa748bbd143e4b4dcd3ff6e4885ffc /report/report_application.rb
parentdb65b03dc761f7788dad5bdbfd9e0d7e8376f6cb (diff)
set content-tpye when accessing ressources, check report types, ...
Diffstat (limited to 'report/report_application.rb')
-rw-r--r--report/report_application.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/report/report_application.rb b/report/report_application.rb
index 83250e8..de8a88e 100644
--- a/report/report_application.rb
+++ b/report/report_application.rb
@@ -31,8 +31,14 @@ get '/report/:type/:id' do
end
get '/report/:type/:id/:resource' do
- #hack: using request.env['REQUEST_URI'].split("/")[-1] instead of params[:resource] because the file extension is lost
- perform{ |rs| result = body(File.new(rs.get_report_resource(params[:type],params[:id],request.env['REQUEST_URI'].split("/")[-1]))) }
+ #hack: using request.env['REQUEST_URI'].split("/")[-1] instead of params[:resource] because the file extension is lost
+
+ perform do |rs|
+ filepath = rs.get_report_resource(params[:type],params[:id],request.env['REQUEST_URI'].split("/")[-1])
+ types = MIME::Types.type_for(filepath)
+ content_type(types[0].content_type) if types and types.size>0 and types[0]
+ result = body(File.new(filepath))
+ end
end
delete '/report/:type/:id' do