Sha256: 44d3f9ae082b066227f6ff67b5103b6a88419ec8297e8e4adfe6f462a18e5379
Contents?: true
Size: 1.38 KB
Versions: 1
Compression:
Stored size: 1.38 KB
Contents
module Mongobile class App < Sinatra::Base include Mongobile::MongoHelper helpers do include Rack::Utils alias_method :h, :escape_html end set :public, File.expand_path("../../../public", __FILE__) set :views, File.expand_path("../../../lib/mongobile/views", __FILE__) before do end get "/" do @databases = connection.database_names haml :index end get "/database/:id" do @database = db(params[:id]) @collections = @database.collections haml :"database/show" end get "/database/:id/:collection" do @database = db(params[:id]) @collection = @database.collection(params[:collection]) haml :"database/collection" end put "/database/:id/:collection" do db.create_collection(params[:collection]) status 201 end post "/database/:id/:collection/delete" do @database = db(params[:id]) @database.drop_collection(params[:collection]) redirect "/database/#{params[:id]}" end post "/database/:id/delete" do connection.drop_database(params[:id]) redirect "/" end post "/database/:id/repair" do @database = db(params[:id]) Thread.start do @database.command({:repairDatabase => 1}) end redirect "/database/#{params[:id]}" end private def error_not_found status 404 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongobile-0.0.4 | lib/mongobile/app.rb |