提交 f7a1c64a 编写于 作者: H Hrvoje Šimić

removed deprecated methods and middlewares

上级 d4fa512d
......@@ -148,20 +148,50 @@ You can swap an existing middleware in the middleware stack using +config.middle
<ruby>
# config/application.rb
# Replace ActionController::Failsafe with Lifo::Failsafe
config.middleware.swap ActionController::Failsafe, Lifo::Failsafe
# Replace ActionDispatch::ShowExceptions with Lifo::ShowExceptions
config.middleware.swap ActionDispatch::ShowExceptions, Lifo::ShowExceptions
</ruby>
h5. Middleware Stack is an Array
The middleware stack behaves just like a normal +Array+. You can use any +Array+ methods to insert, reorder, or remove items from the stack. Methods described in the section above are just convenience methods.
For example, the following removes the middleware matching the supplied class name:
Append following lines to your application configuration:
<ruby>
config.middleware.delete(middleware)
# config/application.rb
config.middleware.delete "Rack::Lock"
config.middleware.delete "ActionDispatch::Cookies"
config.middleware.delete "ActionDispatch::Flash"
config.middleware.delete "ActionDispatch::RemoteIp"
config.middleware.delete "ActionDispatch::Reloader"
config.middleware.delete "ActionDispatch::Callbacks"
</ruby>
And now inspecting the middleware stack:
<shell>
$ rake middleware
(in /Users/lifo/Rails/blog)
use ActionDispatch::Static
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000001c304c8>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Session::CookieStore
use ActionDispatch::ParamsParser
use ActionDispatch::Head
use Rack::ConditionalGet
use Rack::ETag
use ActionDispatch::BestStandardsSupport
run Myapp::Application.routes
</shell>
h4. Internal Middleware Stack
Much of Action Controller's functionality is implemented as Middlewares. The following list explains the purpose of each of them:
......@@ -234,32 +264,6 @@ Much of Action Controller's functionality is implemented as Middlewares. The fol
TIP: It's possible to use any of the above middlewares in your custom Rack stack.
h4. Customizing Internal Middleware Stack
It's possible to replace the entire middleware stack with a custom stack using <tt>ActionController::Dispatcher.middleware=</tt>.
Put the following in an initializer:
<ruby>
# config/initializers/stack.rb
ActionController::Dispatcher.middleware = ActionController::MiddlewareStack.new do |m|
m.use ActionController::Failsafe
m.use ActiveRecord::QueryCache
m.use Rack::Head
end
</ruby>
And now inspecting the middleware stack:
<shell>
$ rake middleware
(in /Users/lifo/Rails/blog)
use ActionController::Failsafe
use ActiveRecord::QueryCache
use Rack::Head
run ActionController::Dispatcher.new
</shell>
h4. Using Rack Builder
The following shows how to replace use +Rack::Builder+ instead of the Rails supplied +MiddlewareStack+.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册