aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2015-04-16 14:55:32 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2015-06-11 16:54:09 -0300
commit135c059d6f0664991f158d358a4312e550ead7a6 (patch)
treee0eea551cb6d77d17b01ca6b52b2d2a46d7ca295 /railties/lib/rails
parent2d86b6d9aec6c46fb6c85a4c504cae48d77c2564 (diff)
downloadrails-135c059d6f0664991f158d358a4312e550ead7a6.tar.gz
rails-135c059d6f0664991f158d358a4312e550ead7a6.tar.bz2
rails-135c059d6f0664991f158d358a4312e550ead7a6.zip
Add config.api_only option to application and remove appropriate middleware when true
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/application/configuration.rb3
-rw-r--r--railties/lib/rails/application/default_middleware_stack.rb6
2 files changed, 5 insertions, 4 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 78a47fcda9..6ffbb1b204 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -13,7 +13,7 @@ module Rails
:railties_order, :relative_url_root, :secret_key_base, :secret_token,
:serve_static_files, :ssl_options, :static_cache_control, :static_index,
:session_options, :time_zone, :reload_classes_only_on_change,
- :beginning_of_week, :filter_redirect, :x
+ :beginning_of_week, :filter_redirect, :api_only, :x
attr_writer :log_level
attr_reader :encoding
@@ -49,6 +49,7 @@ module Rails
@eager_load = nil
@secret_token = nil
@secret_key_base = nil
+ @api_only = false
@x = Custom.new
end
diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb
index 909ed5cc35..6f9ccec137 100644
--- a/railties/lib/rails/application/default_middleware_stack.rb
+++ b/railties/lib/rails/application/default_middleware_stack.rb
@@ -28,7 +28,7 @@ module Rails
middleware.use ::Rack::Lock unless allow_concurrency?
middleware.use ::Rack::Runtime
- middleware.use ::Rack::MethodOverride
+ middleware.use ::Rack::MethodOverride unless config.api_only
middleware.use ::ActionDispatch::RequestId
# Must come after Rack::MethodOverride to properly log overridden methods
@@ -42,9 +42,9 @@ module Rails
end
middleware.use ::ActionDispatch::Callbacks
- middleware.use ::ActionDispatch::Cookies
+ middleware.use ::ActionDispatch::Cookies unless config.api_only
- if config.session_store
+ if !config.api_only && config.session_store
if config.force_ssl && !config.session_options.key?(:secure)
config.session_options[:secure] = true
end