Skip to content

Instantly share code, notes, and snippets.

@tony612
Last active December 21, 2015 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tony612/6338809 to your computer and use it in GitHub Desktop.
Save tony612/6338809 to your computer and use it in GitHub Desktop.
middlewares of rails
$ rake middleware
use ActionDispatch::Static
- servers static files under "public" directory
use Rack::Lock
- locks the rest of the application to a single thread
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007fcc36ff3c00>
- flushes memory based store used internally by Rails.cache
use Rack::Runtime
- adds X-Runtime to response header providing number of seconds to process rest of the app
use Rack::MethodOverride
- sets the HTTP request method based on "_method" parameter
use ActionDispatch::RequestId
- assigns a unique id to the request and adds X-Request-Id response header
use Rails::Rack::Logger
- logs beginning of request and flushes log after request
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
- catches exceptions and displays them on a pretty page
use ActionDispatch::RemoteIp
- captures the remote IP address for later use
use ActionDispatch::Reloader
- reloads classes in development
use ActionDispatch::Callbacks
- provides before/after callback hook
use ActiveRecord::ConnectionAdapters::ConnectionManagement
- clears active database connections
use ActiveRecord::QueryCache
- clears query cache at the end of each request
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
- persists flash, session, and cookies between requests
use ActionDispatch::ParamsParser
- parses different formatted requests (XML/JSON) into params hash
use ActionDispatch::Head
- strips out response body on HEAD requests
use Rack::ConditionalGet
use Rack::ETag
- strips out response body when it has not been modified
use ActionDispatch::BestStandardsSupport
- tells Internet Explorer to use Chrome Frame or latest rendering engine
run Blog::Application.routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment