Class: Sinatra::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/overwrite.rb

Instance Method Summary collapse

Instance Method Details

#return_task(task) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/overwrite.rb', line 42

def return_task( task )
  raise "http_code == nil" unless task.http_code!=nil
  case request.env['HTTP_ACCEPT']
  when /rdf/
    response['Content-Type'] = "application/rdf+xml"
    halt task.http_code,task.to_rdfxml
  when /yaml/
    response['Content-Type'] = "application/x-yaml"
    halt task.http_code,task.to_yaml # PENDING differs from task-webservice
  when /html/
    response['Content-Type'] = "text/html"
    # html -> task created with html form -> redirect to task uri
    redirect task.uri 
  else # default /uri-list/
    response['Content-Type'] = "text/uri-list"
    if task.completed?
      halt task.http_code,task.resultURI+"\n"
    else
      halt task.http_code,task.uri+"\n"
    end
  end
end