Created
May 11, 2016 11:52
-
-
Save strzibny/22123527b699ae98919d57199f42499b to your computer and use it in GitHub Desktop.
Rails default middleware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# http://guides.rubyonrails.org/v3.2.8/rails_on_rack.html | |
require 'rack' | |
require 'rails/all' | |
# Defaults are defined in railties/lib/rails/application/default_middleware_stack.rb | |
class Application < Rails::Application | |
routes.draw do | |
root to: Proc.new { [200, {'Content-Type' => 'text/html'}, ["Hello from app"]] } | |
end | |
configure do | |
# if config.force_ssl | |
middleware.use ActionDispatch::SSL | |
middleware.use Rack::Sendfile | |
# if config.public_file_server.enabled | |
middleware.use ActionDispatch::Static | |
# if config.action_dispatch.rack_cache | |
# require "action_dispatch/http/rack_cache" | |
# middleware.use ::Rack::Cache, rack_cache | |
# if config.allow_concurrency == false | |
middleware.use Rack::Lock | |
# middleware.use ::ActionDispatch::Executor, app.executor | |
middleware.use ::Rack::Runtime | |
# if config.api_only == false | |
# middleware.use ::Rack::MethodOverride | |
middleware.use ActionDispatch::RequestId | |
middleware.use Rails::Rack::Logger | |
middleware.use ActionDispatch::ShowExceptions | |
middleware.use ActionDispatch::DebugExceptions | |
middleware.use ActionDispatch::RemoteIp | |
# if config.cache_classes == false | |
# middleware.use ActionDispatch::Reloader, app.reloader | |
middleware.use ActionDispatch::Callbacks | |
# if config.api_only == false | |
middleware.use ::ActionDispatch::Cookies | |
# if config.api_only == false and config.session_store | |
# middleware.use config.session_store, config.session_options | |
# middleware.use ::ActionDispatch::Flash | |
# middleware.use ActionDispatch::Head | |
middleware.use Rack::ConditionalGet | |
middleware.use Rack::ETag, "no-cache" | |
end | |
end | |
Rack::Handler::WEBrick.run Application.routes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment