diff options
Diffstat (limited to 'guides/source/rails_on_rack.md')
-rw-r--r-- | guides/source/rails_on_rack.md | 68 |
1 files changed, 45 insertions, 23 deletions
diff --git a/guides/source/rails_on_rack.md b/guides/source/rails_on_rack.md index 98e96f2643..0e59395c8a 100644 --- a/guides/source/rails_on_rack.md +++ b/guides/source/rails_on_rack.md @@ -143,7 +143,7 @@ Purpose of each of this middlewares is explained in the [Internal Middlewares](# ### Configuring Middleware Stack -Rails provides a simple configuration interface `config.middleware` for adding, removing and modifying the middlewares in the middleware stack via `application.rb` or the environment specific configuration file `environments/<environment>.rb`. +Rails provides a simple configuration interface `config.middleware` for adding, removing and modifying the middlewares in the middleware stack via `application.rb` or the environment specific configuration file `environments/<environment>.rb`. #### Adding a Middleware @@ -221,70 +221,92 @@ config.middleware.delete "Rack::MethodOverride" Much of Action Controller's functionality is implemented as Middlewares. The following list explains the purpose of each of them: - *`ActionDispatch::Static`* + **`ActionDispatch::Static`** + * Used to serve static assets. Disabled if `config.serve_static_assets` is true. - *`Rack::Lock`* + **`Rack::Lock`** + * Sets `env["rack.multithread"]` flag to `true` and wraps the application within a Mutex. - *`ActiveSupport::Cache::Strategy::LocalCache::Middleware`* + **`ActiveSupport::Cache::Strategy::LocalCache::Middleware`** + * Used for memory caching. This cache is not thread safe. - *`Rack::Runtime`* + **`Rack::Runtime`** + * Sets an X-Runtime header, containing the time (in seconds) taken to execute the request. - *`Rack::MethodOverride`* + **`Rack::MethodOverride`** + * Allows the method to be overridden if `params[:_method]` is set. This is the middleware which supports the PUT and DELETE HTTP method types. - *`ActionDispatch::RequestId`* + **`ActionDispatch::RequestId`** + * Makes a unique `X-Request-Id` header available to the response and enables the `ActionDispatch::Request#uuid` method. - *`Rails::Rack::Logger`* + **`Rails::Rack::Logger`** + * Notifies the logs that the request has began. After request is complete, flushes all the logs. - *`ActionDispatch::ShowExceptions`* + **`ActionDispatch::ShowExceptions`** + * Rescues any exception returned by the application and calls an exceptions app that will wrap it in a format for the end user. - *`ActionDispatch::DebugExceptions`* + **`ActionDispatch::DebugExceptions`** + * Responsible for logging exceptions and showing a debugging page in case the request is local. - *`ActionDispatch::RemoteIp`* + **`ActionDispatch::RemoteIp`** + * Checks for IP spoofing attacks. - *`ActionDispatch::Reloader`* + **`ActionDispatch::Reloader`** + * Provides prepare and cleanup callbacks, intended to assist with code reloading during development. - *`ActionDispatch::Callbacks`* + **`ActionDispatch::Callbacks`** + * Runs the prepare callbacks before serving the request. - *`ActiveRecord::ConnectionAdapters::ConnectionManagement`* + **`ActiveRecord::ConnectionAdapters::ConnectionManagement`** + * Cleans active connections after each request, unless the `rack.test` key in the request environment is set to `true`. - *`ActiveRecord::QueryCache`* + **`ActiveRecord::QueryCache`** + * Enables the Active Record query cache. - *`ActionDispatch::Cookies`* + **`ActionDispatch::Cookies`** + * Sets cookies for the request. - *`ActionDispatch::Session::CookieStore`* + **`ActionDispatch::Session::CookieStore`** + * Responsible for storing the session in cookies. - *`ActionDispatch::Flash`* + **`ActionDispatch::Flash`** + * Sets up the flash keys. Only available if `config.action_controller.session_store` is set to a value. - *`ActionDispatch::ParamsParser`* + **`ActionDispatch::ParamsParser`** + * Parses out parameters from the request into `params`. - *`ActionDispatch::Head`* + **`ActionDispatch::Head`** + * Converts HEAD requests to `GET` requests and serves them as so. - *`Rack::ConditionalGet`* + **`Rack::ConditionalGet`** + * Adds support for "Conditional `GET`" so that server responds with nothing if page wasn't changed. - *`Rack::ETag`* + **`Rack::ETag`** + * Adds ETag header on all String bodies. ETags are used to validate cache. - *`ActionDispatch::BestStandardsSupport`* + **`ActionDispatch::BestStandardsSupport`** + * Enables “best standards support” so that IE8 renders some elements correctly. TIP: It's possible to use any of the above middlewares in your custom Rack stack. |