Class: Appcast::MessageHandler
- Inherits:
-
BaseHandler
- Object
- Mongrel::HttpHandler
- BaseHandler
- Appcast::MessageHandler
- Defined in:
- lib/appcast/handlers.rb
Constant Summary collapse
- ID_SCANNER =
/\/(\d+)$/.freeze
Instance Method Summary collapse
Methods inherited from BaseHandler
Constructor Details
This class inherits a constructor from Appcast::BaseHandler
Instance Method Details
#process(request, response) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/appcast/handlers.rb', line 66 def process(request, response) pre_process id = request.path.scan(ID_SCANNER)[0].first case request.method when 'DELETE' @guard.synchronize { Message.destroy(id) } response.start(200) {} when 'PUT' @guard.synchronize { Message.find(id).unlock } response.start(200) {} when 'GET' msg = nil @guard.synchronize { msg = Message.find(id) } response.start { |h,out| h['Location'] = msg.location; out.write(msg.to_xml) } end rescue ActiveRecord::RecordNotFound response.start(404) { |h,out| out.write("Unknown message with id #{id}") } rescue => e puts e. puts e.backtrace.join("\n") response.start(500) {} end |