lib/monocle/server.rb in monocle-0.2.1 vs lib/monocle/server.rb in monocle-0.2.2
- old
+ new
@@ -1,10 +1,18 @@
require 'sinatra/base'
module Monocle
class Server < Sinatra::Base
- post '/:type/:id(.:format)' do
- if object = params[:type].classify.constantize.find(params[:id])
+ post '/:type/:id.:format' do
+ view_object(params[:type], params[:id])
+ end
+
+ get '/:type/:id.:format' do
+ view_object(params[:type], params[:id])
+ end
+
+ def view_object(type, id)
+ if object = type.classify.constantize.find(id)
object.view!
'o_0 +1'
else
'o_0'
end