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
|
||||
def reset!
|
||||
@app = nil
|
||||
end
|
||||
|
||||
# The shared Rack instance being build
|
||||
#
|
||||
# @private
|
||||
# @return [Rack::Builder]
|
||||
def app
|
||||
@app ||= ::Rack::Builder.new
|
||||
@rack_app = nil
|
||||
end
|
||||
|
||||
# Get the static instance
|
||||
|
@ -74,22 +66,24 @@ module Middleman
|
|||
# @private
|
||||
# @return [Rack::Builder]
|
||||
def to_rack_app(&block)
|
||||
inner_app = inst(&block)
|
||||
|
||||
@rack_app ||= begin
|
||||
app = ::Rack::Builder.new
|
||||
app.use Rack::Lint
|
||||
|
||||
(@middleware || []).each do |m|
|
||||
app.use(m[0], *m[1], &m[2])
|
||||
Array(@middleware).each do |klass, options, blockm|
|
||||
app.use(klass, *options, &block)
|
||||
end
|
||||
|
||||
inner_app = inst(&block)
|
||||
app.map("/") { run inner_app }
|
||||
|
||||
(@mappings || []).each do |m|
|
||||
app.map(m[0], &m[1])
|
||||
Array(@mappings).each do |path, block|
|
||||
app.map(path, &block)
|
||||
end
|
||||
|
||||
app
|
||||
end
|
||||
end
|
||||
|
||||
# Prototype app. Used in config.ru
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue