Remove global access to the rack env and response
This commit is contained in:
parent
16ca3d5c17
commit
fdd52cd640
|
@ -180,14 +180,6 @@ module Middleman
|
||||||
delegate :use, :to => :"self.class"
|
delegate :use, :to => :"self.class"
|
||||||
delegate :map, :to => :"self.class"
|
delegate :map, :to => :"self.class"
|
||||||
|
|
||||||
# Rack env
|
|
||||||
def env
|
|
||||||
Thread.current[:env]
|
|
||||||
end
|
|
||||||
def env=(value)
|
|
||||||
Thread.current[:env] = value
|
|
||||||
end
|
|
||||||
|
|
||||||
# Rack request
|
# Rack request
|
||||||
# @return [Rack::Request]
|
# @return [Rack::Request]
|
||||||
def req
|
def req
|
||||||
|
@ -197,15 +189,6 @@ module Middleman
|
||||||
Thread.current[:req] = value
|
Thread.current[:req] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Rack response
|
|
||||||
# @return [Rack::Response]
|
|
||||||
def res
|
|
||||||
Thread.current[:res]
|
|
||||||
end
|
|
||||||
def res=(value)
|
|
||||||
Thread.current[:res] = value
|
|
||||||
end
|
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
dup.call!(env)
|
dup.call!(env)
|
||||||
end
|
end
|
||||||
|
@ -214,10 +197,9 @@ module Middleman
|
||||||
#
|
#
|
||||||
# @param env Rack environment
|
# @param env Rack environment
|
||||||
def call!(env)
|
def call!(env)
|
||||||
self.env = env
|
|
||||||
# Store environment, request and response for later
|
# Store environment, request and response for later
|
||||||
self.req = req = ::Rack::Request.new(env)
|
self.req = req = ::Rack::Request.new(env)
|
||||||
self.res = res = ::Rack::Response.new
|
res = ::Rack::Response.new
|
||||||
|
|
||||||
logger.debug "== Request: #{env["PATH_INFO"]}"
|
logger.debug "== Request: #{env["PATH_INFO"]}"
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ module Middleman
|
||||||
app.data.store("page", md[:page])
|
app.data.store("page", md[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
blocks = md[:blocks].dup rescue []
|
blocks = Array(md[:blocks]).dup
|
||||||
blocks << block if block_given?
|
blocks << block if block_given?
|
||||||
|
|
||||||
app.current_path ||= self.destination_path
|
app.current_path ||= self.destination_path
|
||||||
|
|
Loading…
Reference in a new issue