mirror of
https://github.com/middleman/middleman.git
synced 2022-11-09 12:20:27 -05:00
Start cleaning up Rack internals
This commit is contained in:
parent
0a288131c1
commit
95eaeba960
8 changed files with 2 additions and 38 deletions
|
@ -1,6 +1,7 @@
|
|||
master
|
||||
===
|
||||
|
||||
* Remove deprecated `request` instance
|
||||
* Remove old module-style extension support
|
||||
* Placed all `config.rb` evaluation inside the `ConfigContext` class
|
||||
|
||||
|
|
|
@ -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"
|
|
@ -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"
|
|
@ -1,3 +0,0 @@
|
|||
with_layout false do
|
||||
page "/request-path.html"
|
||||
end
|
|
@ -1 +0,0 @@
|
|||
<%= current_path == request.path %>
|
|
@ -1,3 +0,0 @@
|
|||
Dot <%= request.params.say %>
|
||||
Quote <%= request.params["say"] %>
|
||||
Symbol <%= request.params[:say] %>
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue