From 4e76efe724aa723e1f79fb09d4e908323720f1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20G=C3=BCtlein?= Date: Wed, 25 Nov 2009 12:40:12 +0100 Subject: set content-tpye when accessing ressources, check report types, ... --- report/report_application.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'report/report_application.rb') 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 -- cgit v1.2.3