aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/application.rb8
-rw-r--r--railties/lib/rails/configuration.rb8
2 files changed, 12 insertions, 4 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb
index 8d64aff430..10fa63c303 100644
--- a/railties/lib/rails/application.rb
+++ b/railties/lib/rails/application.rb
@@ -239,7 +239,7 @@ module Rails
middleware.use ::Rack::Lock unless config.allow_concurrency
middleware.use ::Rack::Runtime
- middleware.use ::Rack::MethodOverride
+ middleware.use ::Rack::MethodOverride unless config.middleware.api_only?
middleware.use ::ActionDispatch::RequestId
middleware.use ::Rails::Rack::Logger, config.log_tags # must come after Rack::MethodOverride to properly log overridden methods
middleware.use ::ActionDispatch::ShowExceptions, config.exceptions_app || ActionDispatch::PublicExceptions.new(Rails.public_path)
@@ -252,9 +252,9 @@ module Rails
end
middleware.use ::ActionDispatch::Callbacks
- middleware.use ::ActionDispatch::Cookies
+ middleware.use ::ActionDispatch::Cookies unless config.middleware.api_only?
- if config.session_store
+ if !config.middleware.api_only? && config.session_store
if config.force_ssl && !config.session_options.key?(:secure)
config.session_options[:secure] = true
end
@@ -267,7 +267,7 @@ module Rails
middleware.use ::Rack::ConditionalGet
middleware.use ::Rack::ETag, "no-cache"
- if config.action_dispatch.best_standards_support
+ if !config.middleware.api_only? && config.action_dispatch.best_standards_support
middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support
end
end
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb
index f8ad17773a..0efa21d82c 100644
--- a/railties/lib/rails/configuration.rb
+++ b/railties/lib/rails/configuration.rb
@@ -9,6 +9,14 @@ module Rails
class MiddlewareStackProxy #:nodoc:
def initialize
@operations = []
+ @api_only = false
+ end
+
+ attr_reader :api_only
+ alias :api_only? :api_only
+
+ def api_only!
+ @api_only = true
end
def insert_before(*args, &block)