Class: Rails::Application::DefaultMiddlewareStack
- Defined in:
- railties/lib/rails/application/default_middleware_stack.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #build_stack ⇒ Object
-
#initialize(app, config, paths) ⇒ DefaultMiddlewareStack
constructor
A new instance of DefaultMiddlewareStack.
Constructor Details
#initialize(app, config, paths) ⇒ DefaultMiddlewareStack
Returns a new instance of DefaultMiddlewareStack.
8 9 10 11 12 |
# File 'railties/lib/rails/application/default_middleware_stack.rb', line 8 def initialize(app, config, paths) @app = app @config = config @paths = paths end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app
6 7 8 |
# File 'railties/lib/rails/application/default_middleware_stack.rb', line 6 def app @app end |
#config ⇒ Object (readonly)
Returns the value of attribute config
6 7 8 |
# File 'railties/lib/rails/application/default_middleware_stack.rb', line 6 def config @config end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths
6 7 8 |
# File 'railties/lib/rails/application/default_middleware_stack.rb', line 6 def paths @paths end |
Instance Method Details
#build_stack ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'railties/lib/rails/application/default_middleware_stack.rb', line 14 def build_stack ActionDispatch::MiddlewareStack.new do |middleware| middleware.use ::ActionDispatch::HostAuthorization, config.hosts, config.action_dispatch.hosts_response_app if config.force_ssl middleware.use ::ActionDispatch::SSL, **config. end middleware.use ::Rack::Sendfile, config.action_dispatch.x_sendfile_header if config.public_file_server.enabled headers = config.public_file_server.headers || {} middleware.use ::ActionDispatch::Static, paths["public"].first, index: config.public_file_server.index_name, headers: headers end if rack_cache = load_rack_cache require "action_dispatch/http/rack_cache" middleware.use ::Rack::Cache, rack_cache end if config.allow_concurrency == false # User has explicitly opted out of concurrent request # handling: presumably their code is not threadsafe middleware.use ::Rack::Lock end middleware.use ::ActionDispatch::Executor, app.executor middleware.use ::Rack::Runtime middleware.use ::Rack::MethodOverride unless config.api_only middleware.use ::ActionDispatch::RequestId middleware.use ::ActionDispatch::RemoteIp, config.action_dispatch.ip_spoofing_check, config.action_dispatch.trusted_proxies middleware.use ::Rails::Rack::Logger, config. middleware.use ::ActionDispatch::ShowExceptions, show_exceptions_app middleware.use ::ActionDispatch::DebugExceptions, app, config.debug_exception_response_format middleware.use ::ActionDispatch::ActionableExceptions unless config.cache_classes middleware.use ::ActionDispatch::Reloader, app.reloader end middleware.use ::ActionDispatch::Callbacks middleware.use ::ActionDispatch::Cookies unless config.api_only if !config.api_only && config.session_store if config.force_ssl && config..fetch(:secure_cookies, true) && !config..key?(:secure) config.[:secure] = true end middleware.use config.session_store, config. middleware.use ::ActionDispatch::Flash end unless config.api_only middleware.use ::ActionDispatch::ContentSecurityPolicy::Middleware middleware.use ::ActionDispatch::FeaturePolicy::Middleware end middleware.use ::Rack::Head middleware.use ::Rack::ConditionalGet middleware.use ::Rack::ETag, "no-cache" middleware.use ::Rack::TempfileReaper unless config.api_only end end |