Skip to content

Commit

Permalink
Fix outdated Rack::Builder rdocs and remove Lobster references (#1986)
Browse files Browse the repository at this point in the history
  • Loading branch information
kennyfrc committed Nov 20, 2022
1 parent 2e13625 commit 4b6def1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
2 changes: 0 additions & 2 deletions lib/rack/auth/basic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ module Auth
#
# Initialize with the Rack application that you want protecting,
# and a block that checks if a username and password pair are valid.
#
# See also: <tt>example/protectedlobster.rb</tt>

class Basic < AbstractHandler

Expand Down
62 changes: 32 additions & 30 deletions lib/rack/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,23 @@ module Rack
#
# Example:
#
# require 'rack/lobster'
# app = Rack::Builder.new do
# use Rack::CommonLogger
# use Rack::ShowExceptions
# map "/lobster" do
# use Rack::Lint
# run Rack::Lobster.new
# end
# end
# app = Rack::Builder.new do
# use Rack::CommonLogger
# map "/ok" do
# run lambda { |env| [200, {'content-type' => 'text/plain'}, ['OK']] }
# end
# end
#
# run app
# run app
#
# Or
#
# app = Rack::Builder.app do
# use Rack::CommonLogger
# run lambda { |env| [200, {'Content-Type' => 'text/plain'}, ['OK']] }
# end
# app = Rack::Builder.app do
# use Rack::CommonLogger
# run lambda { |env| [200, {'content-type' => 'text/plain'}, ['OK']] }
# end
#
# run app
# run app
#
# +use+ adds middleware to the stack, +run+ dispatches to an application.
# You can use +map+ to construct a Rack::URLMap in a convenient way.
Expand Down Expand Up @@ -180,15 +177,6 @@ def use(middleware, *args, &block)
#
# run Heartbeat.new
#
# It could also be a module:
#
# module HelloWorld
# def call(env)
# [200, { "content-type" => "text/plain" }, ["Hello World"]]
# end
# end
#
# run HelloWorld
def run(app = nil, &block)
raise ArgumentError, "Both app and block given!" if app && block_given?

Expand All @@ -213,21 +201,35 @@ def warmup(prc = nil, &block)
# the Rack application specified by run inside the block. Other requests will be sent to the
# default application specified by run outside the block.
#
# Rack::Builder.app do
# class App
# def call(env)
# [200, {'content-type' => 'text/plain'}, ["Hello World"]]
# end
# end
#
# class Heartbeat
# def call(env)
# [200, { "content-type" => "text/plain" }, ["OK"]]
# end
# end
#
# app = Rack::Builder.app do
# map '/heartbeat' do
# run Heartbeat
# run Heartbeat.new
# end
# run App
# run App.new
# end
#
# run app
#
# The +use+ method can also be used inside the block to specify middleware to run under a specific path:
#
# Rack::Builder.app do
# app = Rack::Builder.app do
# map '/heartbeat' do
# use Middleware
# run Heartbeat
# run Heartbeat.new
# end
# run App
# run App.new
# end
#
# This example includes a piece of middleware which will run before +/heartbeat+ requests hit +Heartbeat+.
Expand Down

0 comments on commit 4b6def1

Please sign in to comment.