From 4ca97288ad2a270c34dc4f18634ee40915a45462 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Thu, 3 Feb 2011 09:45:18 +0100 Subject: return task method for sinatra --- lib/overwrite.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib/overwrite.rb') diff --git a/lib/overwrite.rb b/lib/overwrite.rb index 1e1cc43..7b53122 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -36,6 +36,27 @@ error Exception do end end +class Sinatra::Base + + def return_task( task ) + code = task.running? ? 202 : 200 + case request.env['HTTP_ACCEPT'] + when /rdf/ + response['Content-Type'] = "application/rdf+xml" + halt code,task.to_rdfxml + when /yaml/ + response['Content-Type'] = "application/rdf+xml" + halt code,task.to_yaml # PENDING differs from task-webservice + when /html/ + response['Content-Type'] = "text/html" + halt code,OpenTox.text_to_html(task.to_yaml) + else # default /uri-list/ + response['Content-Type'] = "text/uri-list" + halt code,task.uri+"\n" + end + end +end + class String def task_uri? self.uri? && !self.match(/task/).nil? -- cgit v1.2.3