Remove global access to the rack env and response

This commit is contained in:
Ben Hollis 2013-04-09 22:12:37 -07:00
parent 16ca3d5c17
commit fdd52cd640
2 changed files with 2 additions and 20 deletions

View file

@ -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"]}"

View file

@ -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