Reorganize Request a bit
This commit is contained in:
parent
8001dab258
commit
ee11ccb184
1 changed files with 15 additions and 21 deletions
|
@ -37,15 +37,7 @@ module Middleman
|
||||||
#
|
#
|
||||||
# @private
|
# @private
|
||||||
def reset!
|
def reset!
|
||||||
@app = nil
|
@rack_app = nil
|
||||||
end
|
|
||||||
|
|
||||||
# The shared Rack instance being build
|
|
||||||
#
|
|
||||||
# @private
|
|
||||||
# @return [Rack::Builder]
|
|
||||||
def app
|
|
||||||
@app ||= ::Rack::Builder.new
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Get the static instance
|
# Get the static instance
|
||||||
|
@ -74,21 +66,23 @@ module Middleman
|
||||||
# @private
|
# @private
|
||||||
# @return [Rack::Builder]
|
# @return [Rack::Builder]
|
||||||
def to_rack_app(&block)
|
def to_rack_app(&block)
|
||||||
inner_app = inst(&block)
|
@rack_app ||= begin
|
||||||
|
app = ::Rack::Builder.new
|
||||||
|
app.use Rack::Lint
|
||||||
|
|
||||||
app.use Rack::Lint
|
Array(@middleware).each do |klass, options, blockm|
|
||||||
|
app.use(klass, *options, &block)
|
||||||
|
end
|
||||||
|
|
||||||
(@middleware || []).each do |m|
|
inner_app = inst(&block)
|
||||||
app.use(m[0], *m[1], &m[2])
|
app.map("/") { run inner_app }
|
||||||
|
|
||||||
|
Array(@mappings).each do |path, block|
|
||||||
|
app.map(path, &block)
|
||||||
|
end
|
||||||
|
|
||||||
|
app
|
||||||
end
|
end
|
||||||
|
|
||||||
app.map("/") { run inner_app }
|
|
||||||
|
|
||||||
(@mappings || []).each do |m|
|
|
||||||
app.map(m[0], &m[1])
|
|
||||||
end
|
|
||||||
|
|
||||||
app
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Prototype app. Used in config.ru
|
# Prototype app. Used in config.ru
|
||||||
|
|
Loading…
Reference in a new issue