summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gütlein <martin.guetlein@gmail.com>2010-04-28 10:23:27 +0200
committerMartin Gütlein <martin.guetlein@gmail.com>2010-04-28 10:23:27 +0200
commit81c8fcfe718f005eb32ebd114f3817dd2a82673f (patch)
treeb1fc005fc6136570385e228ec4e82c95c33d163b
parent0724299d8ec899113f18734f30e33689fbaeb7ac (diff)
return 202/201/200 for tasks
-rw-r--r--application.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/application.rb b/application.rb
index 92ba5a5..0f82931 100644
--- a/application.rb
+++ b/application.rb
@@ -38,16 +38,18 @@ get '/:id/?' do
halt 404, "Task #{params[:id]} not found." unless task
+ code = task.hasStatus == "Running" ? 202 : 200
+
case request.env['HTTP_ACCEPT']
when /text\/x-yaml|\*\/\*/ # matches 'text/x-yaml', '*/*'
response['Content-Type'] = 'text/x-yaml'
task_content[:uri] = task.uri
- task_content.to_yaml
+ halt code, task_content.to_yaml
when /application\/rdf\+xml|\*\/\*/
response['Content-Type'] = 'application/rdf+xml'
owl = OpenTox::Owl.create 'Task', task.uri
task_content.each{ |k,v| owl.set(k.to_s,v)}
- owl.rdf
+ halt code, owl.rdf
else
halt 400, "MIME type '"+request.env['HTTP_ACCEPT'].to_s+"' not supported, valid Accept-Headers are \"application/rdf+xml\" and \"text/x-yaml\"."
end