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,22 +66,24 @@ 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
|
||||||
|
|
||||||
(@middleware || []).each do |m|
|
Array(@middleware).each do |klass, options, blockm|
|
||||||
app.use(m[0], *m[1], &m[2])
|
app.use(klass, *options, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
inner_app = inst(&block)
|
||||||
app.map("/") { run inner_app }
|
app.map("/") { run inner_app }
|
||||||
|
|
||||||
(@mappings || []).each do |m|
|
Array(@mappings).each do |path, block|
|
||||||
app.map(m[0], &m[1])
|
app.map(path, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
app
|
app
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Prototype app. Used in config.ru
|
# Prototype app. Used in config.ru
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue