Permalink
Browse files

Rack::Builder#map: Public and private resources

  • Loading branch information...
1 parent 0dc23ef commit b30d680c980038cdc15535a8104133704b45f149 @jcarlosgarcia committed Feb 25, 2012
Showing with 25 additions and 0 deletions.
  1. +24 −0 rack_builder/rack_builder_map/config.ru
  2. +1 −0 rack_builder/rack_builder_map/rack.log
@@ -0,0 +1,24 @@
+require 'logger'
+rack_app = Rack::Builder.new do
+ use Rack::CommonLogger
+ Logger.new('rack.log')
+
+ map "/" do
+ run Proc.new {|env| [200, {"Content-Type" => "text/html"}, ["This is a public page"]]}
+ end
+
+ map "/secret" do
+ use Rack::Auth::Basic, "Restricted Area" do |user, password|
+ user == 'super' && password == 'secretsauce'
+ end
+
+ map "/" do
+ run Proc.new {|env| [200, {"Content-Type" => "text/html"}, ["This is a secret page"]]}
+ end
+
+ map "/files" do
+ run Proc.new {|env| [200, {"Content-Type" => "text/html"}, ["Here are the secret files"]]}
+ end
+ end
+end
+Rack::Handler::WEBrick.run rack_app, :Port => 9292
@@ -0,0 +1 @@
+# Logfile created on 2012-02-25 17:36:25 +0100 by logger.rb/v1.2.7

0 comments on commit b30d680

Please sign in to comment.