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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/appcast/handlers.rb', line 59 def process(request, response) 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 |