diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-02-03 09:45:18 +0100 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-02-03 09:45:18 +0100 |
commit | 4ca97288ad2a270c34dc4f18634ee40915a45462 (patch) | |
tree | e7610a15f1143523f7221ecbf201695faa0357b6 /lib/overwrite.rb | |
parent | 70aee6e9dfece2760fc6d616e7151f41cc7625bf (diff) |
return task method for sinatra
Diffstat (limited to 'lib/overwrite.rb')
-rw-r--r-- | lib/overwrite.rb | 21 |
1 files changed, 21 insertions, 0 deletions
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? |