diff options
-rw-r--r-- | application.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/application.rb b/application.rb index ed2319c..064d107 100644 --- a/application.rb +++ b/application.rb @@ -27,17 +27,17 @@ DataMapper.auto_upgrade! get '/?' do response['Content-Type'] = 'text/uri-list' - Task.all.collect{|t| t.uri}.join("\n") + "\n" + Task.all(params).collect{|t| t.uri}.join("\n") + "\n" end get '/:id/?' do task = Task.get(params[:id]) + halt 404, "Task '#{params[:id]}' not found." unless task + task_content = {:creator => task.creator, :title => task.title, :date => task.created_at.to_s, :hasStatus => task.hasStatus, :resultURI => task.resultURI, :percentageCompleted => task.percentageCompleted, :description => task.description, :due_to_time => task.due_to_time.to_s} - halt 404, "Task #{params[:id]} not found." unless task - code = task.hasStatus == "Running" ? 202 : 200 case request.env['HTTP_ACCEPT'] @@ -58,7 +58,8 @@ end # dynamic access to Task properties get '/:id/:property/?' do response['Content-Type'] = 'text/plain' - task = Task.get(params[:id]) + task = Task.get(params[:id]) + halt 404,"Task #{params[:id]} not found." unless task eval("task.#{params[:property]}").to_s end |