Class: Xapit::Server::App
- Inherits:
-
Object
- Object
- Xapit::Server::App
- Defined in:
- lib/xapit/server/app.rb
Instance Method Summary collapse
Instance Method Details
#action(command, json) ⇒ Object
14 15 16 17 |
# File 'lib/xapit/server/app.rb', line 14 def action(command, json) data = Xapit.symbolize_keys(JSON.parse(json)) render :content => Xapit.database.send(command, data).to_json end |
#call(env) ⇒ Object
4 5 6 7 8 9 10 11 12 |
# File 'lib/xapit/server/app.rb', line 4 def call(env) request = Rack::Request.new(env) command = request.path[%r</xapit/(.+)>, 1] if Database::COMMANDS.include? command action(command, request.body.gets) else render :status => 404 end end |
#render(options = {}) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/xapit/server/app.rb', line 19 def render( = {}) [:status] ||= 200 [:content] ||= "" [:content_type] ||= "text/html" [[:status], {"Content-Type" => [:content_type]}, [[:content]]] end |