Skip to content

Commit

Permalink
Move HTTP libs and middleware into ActionDispatch component
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jan 28, 2009
1 parent a0f2b1d commit 319ae46
Show file tree
Hide file tree
Showing 44 changed files with 134 additions and 427 deletions.
32 changes: 3 additions & 29 deletions actionpack/lib/action_controller.rb
Expand Up @@ -31,58 +31,43 @@
end
end

gem 'rack', '>= 0.9.0'
require 'rack'
require 'action_controller/rack_ext'

require File.join(File.dirname(__FILE__), "action_pack")

module ActionController
# TODO: Review explicit to see if they will automatically be handled by
# the initilizer if they are really needed.
def self.load_all!
[Base, CGIHandler, CgiRequest, Request, Response, Http::Headers, UrlRewriter, UrlWriter]
[Base, Request, Response, UrlRewriter, UrlWriter]
[ActionDispatch::Http::Headers]
end

autoload :Base, 'action_controller/base/base'
autoload :Benchmarking, 'action_controller/base/chained/benchmarking'
autoload :Caching, 'action_controller/caching'
autoload :Cookies, 'action_controller/base/cookies'
autoload :Dispatcher, 'action_controller/dispatch/dispatcher'
autoload :Failsafe, 'action_controller/dispatch/rack/failsafe'
autoload :Filters, 'action_controller/base/chained/filters'
autoload :Flash, 'action_controller/base/chained/flash'
autoload :Helpers, 'action_controller/base/helpers'
autoload :HttpAuthentication, 'action_controller/base/http_authentication'
autoload :Integration, 'action_controller/testing/integration'
autoload :IntegrationTest, 'action_controller/testing/integration'
autoload :Layout, 'action_controller/base/layout'
autoload :Lock, 'action_controller/dispatch/rack/lock'
autoload :MiddlewareStack, 'action_controller/dispatch/rack/middleware_stack'
autoload :MimeResponds, 'action_controller/mime/responds'
autoload :ParamsParser, 'action_controller/dispatch/params_parser'
autoload :PolymorphicRoutes, 'action_controller/routing/generation/polymorphic_routes'
autoload :RecordIdentifier, 'action_controller/record_identifier'
autoload :Redirector, 'action_controller/base/redirect'
autoload :Renderer, 'action_controller/base/render'
autoload :Request, 'action_controller/dispatch/request'
autoload :RequestForgeryProtection, 'action_controller/base/request_forgery_protection'
autoload :RequestParser, 'action_controller/dispatch/request_parser'
autoload :Rescue, 'action_controller/dispatch/rescue'
autoload :Resources, 'action_controller/routing/resources'
autoload :Responder, 'action_controller/base/responder'
autoload :Response, 'action_controller/dispatch/response'
autoload :RewindableInput, 'action_controller/dispatch/rewindable_input'
autoload :Routing, 'action_controller/routing'
autoload :SessionManagement, 'action_controller/session/management'
autoload :StatusCodes, 'action_controller/dispatch/status_codes'
autoload :Streaming, 'action_controller/base/streaming'
autoload :TestCase, 'action_controller/testing/test_case'
autoload :TestProcess, 'action_controller/testing/process'
autoload :Translation, 'action_controller/translation'
autoload :UploadedFile, 'action_controller/dispatch/uploaded_file'
autoload :UploadedStringIO, 'action_controller/dispatch/uploaded_file'
autoload :UploadedTempfile, 'action_controller/dispatch/uploaded_file'
autoload :UrlEncodedPairParser, 'action_controller/dispatch/url_encoded_pair_parser'
autoload :UrlRewriter, 'action_controller/routing/generation/url_rewriter'
autoload :UrlWriter, 'action_controller/routing/generation/url_rewriter'
Expand All @@ -96,20 +81,9 @@ module Assertions
autoload :SelectorAssertions, 'action_controller/testing/assertions/selector'
autoload :TagAssertions, 'action_controller/testing/assertions/tag'
end

module Http
autoload :Headers, 'action_controller/base/headers'
end

module Session
autoload :AbstractStore, 'action_controller/session/abstract_store'
autoload :CookieStore, 'action_controller/session/cookie_store'
autoload :MemCacheStore, 'action_controller/session/mem_cache_store'
end
end

autoload :Mime, 'action_controller/mime/type'

autoload :HTML, 'action_controller/vendor/html-scanner'

require 'action_dispatch'
require 'action_view'
6 changes: 3 additions & 3 deletions actionpack/lib/action_controller/base/base.rb
Expand Up @@ -232,7 +232,7 @@ class UnknownHttpMethod < ActionControllerError #:nodoc:
#
class Base

include StatusCodes
include ActionDispatch::StatusCodes

cattr_reader :protected_instance_variables
# Controller specific instance variables which will not be accessible inside views.
Expand Down Expand Up @@ -367,8 +367,8 @@ class Base
class << self
def call(env)
# HACK: For global rescue to have access to the original request and response
request = env["action_controller.rescue.request"] ||= Request.new(env)
response = env["action_controller.rescue.response"] ||= Response.new
request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env)
response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new
process(request, response)
end

Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/dispatch/dispatcher.rb
Expand Up @@ -45,8 +45,8 @@ def to_prepare(identifier = nil, &block)
end

cattr_accessor :middleware
self.middleware = MiddlewareStack.new do |middleware|
middlewares = File.join(File.dirname(__FILE__), "rack", "middlewares.rb")
self.middleware = ActionDispatch::MiddlewareStack.new do |middleware|
middlewares = File.join(File.dirname(__FILE__), "middlewares.rb")
middleware.instance_eval(File.read(middlewares))
end

Expand Down
Expand Up @@ -2,10 +2,10 @@
!ActionController::Base.allow_concurrency
}

use "ActionController::Failsafe"
use "ActionDispatch::Failsafe"

["ActionController::Session::CookieStore",
"ActionController::Session::MemCacheStore",
["ActionDispatch::Session::CookieStore",
"ActionDispatch::Session::MemCacheStore",
"ActiveRecord::SessionStore"].each do |store|
use(store, ActionController::Base.session_options,
:if => lambda {
Expand All @@ -16,6 +16,6 @@
)
end

use "ActionController::RewindableInput"
use "ActionController::ParamsParser"
use "ActionDispatch::RewindableInput"
use "ActionDispatch::ParamsParser"
use "Rack::MethodOverride"
16 changes: 0 additions & 16 deletions actionpack/lib/action_controller/dispatch/rack/lock.rb

This file was deleted.

0 comments on commit 319ae46

Please sign in to comment.