Start cleaning up Rack internals

i18n_v4
Thomas Reynolds 2014-01-01 19:09:47 -08:00
parent 0a288131c1
commit 95eaeba960
8 changed files with 2 additions and 38 deletions

View File

@ -1,6 +1,7 @@
master
===
* Remove deprecated `request` instance
* Remove old module-style extension support
* Placed all `config.rb` evaluation inside the `ConfigContext` class

View File

@ -1,6 +0,0 @@
Feature: Support old request.path object used by many extensions
Scenario: Viewing the root path
Given the Server is running at "current-page-app"
When I go to "/request-path.html"
Then I should see "true"

View File

@ -1,6 +0,0 @@
Feature: Support request parameters
Scenario: Use request params in a template
Given the Server is running at "request-app"
When I go to "/index.html?say=Hello+World"
Then I should see "Quote Hello World"
Then I should see "Symbol Hello World"

View File

@ -1,3 +0,0 @@
with_layout false do
page "/request-path.html"
end

View File

@ -1 +0,0 @@
<%= current_path == request.path %>

View File

@ -1,3 +0,0 @@
Dot <%= request.params.say %>
Quote <%= request.params["say"] %>
Symbol <%= request.params[:say] %>

View File

@ -151,10 +151,6 @@ module Middleman
# Methods to be mixed-in to Middleman::Application
module InstanceMethods
# Backwards-compatibility with old request.path signature
def request
Thread.current[:legacy_request]
end
# Accessor for current path
# @return [String]
@ -168,24 +164,11 @@ module Middleman
# @return [void]
def current_path=(path)
Thread.current[:current_path] = path
Thread.current[:legacy_request] = ::Thor::CoreExt::HashWithIndifferentAccess.new({
:path => path,
:params => req ? ::Thor::CoreExt::HashWithIndifferentAccess.new(req.params) : {}
})
end
delegate :use, :to => :"self.class"
delegate :map, :to => :"self.class"
# Rack request
# @return [Rack::Request]
def req
Thread.current[:req]
end
def req=(value)
Thread.current[:req] = value
end
def call(env)
dup.call!(env)
end
@ -195,7 +178,7 @@ module Middleman
# @param env Rack environment
def call!(env)
# Store environment, request and response for later
self.req = req = ::Rack::Request.new(env)
req = ::Rack::Request.new(env)
res = ::Rack::Response.new
logger.debug "== Request: #{env["PATH_INFO"]}"
@ -253,7 +236,6 @@ module Middleman
begin
# Write out the contents of the page
output = resource.render do
self.req = req
self.current_path = current_path
end