diff options
author | Yehuda Katz <wycats@yehuda-katzs-macbookpro41.local> | 2009-05-27 10:40:43 +0200 |
---|---|---|
committer | Yehuda Katz <wycats@yehuda-katzs-macbookpro41.local> | 2009-05-27 10:40:43 +0200 |
commit | 6bbe965ccdcef2d7e713e65175722718d325b2bd (patch) | |
tree | 5c9fc1d58b3f9ef692a356c49638d78611a51948 /actionpack/lib/action_controller/new_base/rack_convenience.rb | |
parent | 311d686d031bbc7074bddd8d56ea42780a204b35 (diff) | |
download | rails-6bbe965ccdcef2d7e713e65175722718d325b2bd.tar.gz rails-6bbe965ccdcef2d7e713e65175722718d325b2bd.tar.bz2 rails-6bbe965ccdcef2d7e713e65175722718d325b2bd.zip |
Reduce the cost of using ActionController::Http significantly by:
* Removing the dependency on AD::Request and AD::Response
* Moving the logic for the request and response object
into a new module that is included by default.
* Changing Renderer and Redirector to use self.headers,
self.content_type, and self.status, which have very basic
default implementations on AC::Http. When RackConvenience
is included (which it is by default on AC::Base), the full
Request/Response logic is used instead of the simple logic.
Diffstat (limited to 'actionpack/lib/action_controller/new_base/rack_convenience.rb')
-rw-r--r-- | actionpack/lib/action_controller/new_base/rack_convenience.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/new_base/rack_convenience.rb b/actionpack/lib/action_controller/new_base/rack_convenience.rb new file mode 100644 index 0000000000..0422ab2f14 --- /dev/null +++ b/actionpack/lib/action_controller/new_base/rack_convenience.rb @@ -0,0 +1,34 @@ +module ActionController + module RackConvenience + extend ActiveSupport::DependencyModule + + included do + delegate :headers, :status=, :location=, + :status, :location, :content_type, :to => "@_response" + attr_internal :request, :response + end + + def call(name, env) + @_request = ActionDispatch::Request.new(env) + @_response = ActionDispatch::Response.new + @_response.request = request + super + end + + def params + @_params ||= @_request.parameters + end + + # :api: private + def to_rack + @_response.prepare! + @_response.to_a + end + + def response_body=(body) + response.body = body if response + super + end + + end +end
\ No newline at end of file |