lib/magent_web/app.rb in magent-0.6.1 vs lib/magent_web/app.rb in magent-0.6.2

- old
+ new

@@ -1,9 +1,20 @@ module MagentWeb class App < Sinatra::Base include MagentWeb::MongoHelper + if MagentWeb.config["enable_auth"] + use Rack::Auth::Basic, "Restricted Area" do |username, password| + [username, password] == [MagentWeb.config["username"], MagentWeb.config["password"]] + end + end + + def initialize(*args) + MagentWeb.connect + super(*args) + end + helpers do include Rack::Utils alias_method :h, :escape_html end @@ -57,16 +68,16 @@ channel = Magent::GenericChannel.new(@channel_name) doc = @errors_queue.find({:_id => params[:id]}).next_document channel.enqueue_error(doc) - redirect "/queues/#{params[:queue_id]}/failed" + redirect "#{queue_path(params[:queue_id])}/failed" end get "/queues/:queue_id/delete/:id" do @errors_queue = @database.collection(params[:queue_id]+".errors") @errors_queue.remove(:_id => params[:id]) - redirect "/queues/#{params[:queue_id]}/failed" + redirect "#{queue_path(params[:queue_id])}/failed" end private def error_not_found status 404