module Middleman::CoreExtensions::Request::ClassMethods
Attributes
inst[W]
Set the shared instance
@private @param [Middleman::Application] inst @return [void]
Public Instance Methods
call(env)
click to toggle source
Call prototype, use in config.ru
@private
# File lib/middleman-core/core_extensions/request.rb, line 99 def call(env) prototype.call(env) end
inst(&block)
click to toggle source
Get the static instance
@private @return [Middleman::Application]
# File lib/middleman-core/core_extensions/request.rb, line 47 def inst(&block) @inst ||= begin mm = new(&block) mm.run_hook :ready mm end end
map(map, &block)
click to toggle source
Add Rack App mapped to specific path
@param [String] map Path to map @return [void]
# File lib/middleman-core/core_extensions/request.rb, line 116 def map(map, &block) @mappings ||= [] @mappings << [map, block] end
prototype()
click to toggle source
Prototype app. Used in config.ru
@private @return [Rack::Builder]
# File lib/middleman-core/core_extensions/request.rb, line 91 def prototype reset! to_rack_app end
reset!()
click to toggle source
Reset Rack setup
@private
# File lib/middleman-core/core_extensions/request.rb, line 39 def reset! @rack_app = nil end
to_rack_app(&block)
click to toggle source
Return built Rack app
@private @return [Rack::Builder]
# File lib/middleman-core/core_extensions/request.rb, line 66 def to_rack_app(&block) @rack_app ||= begin app = ::Rack::Builder.new app.use Rack::Lint app.use Rack::Head Array(@middleware).each do |klass, options, middleware_block| app.use(klass, *options, &middleware_block) end inner_app = inst(&block) app.map('/') { run inner_app } Array(@mappings).each do |path, map_block| app.map(path, &map_block) end app end end
use(middleware, *args, &block)
click to toggle source
Use Rack middleware
@param [Class] middleware Middleware module @return [void]
# File lib/middleman-core/core_extensions/request.rb, line 107 def use(middleware, *args, &block) @middleware ||= [] @middleware << [middleware, args, block] end