aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/metal/default_headers.rb
diff options
context:
space:
mode:
authorKevin Deisz <kevin.deisz@gmail.com>2018-04-06 15:13:28 -0400
committerKevin Deisz <kevin.deisz@gmail.com>2018-04-06 15:13:28 -0400
commitf22bc41a92e8f51d6f6da5b840f3364474d6aaba (patch)
tree96d039056180b5228f715160fcfae41a5e7126fc /actionpack/lib/action_controller/metal/default_headers.rb
parent03bd370c02a8fa83ab6dd01bdd99fe342c523b81 (diff)
downloadrails-f22bc41a92e8f51d6f6da5b840f3364474d6aaba.tar.gz
rails-f22bc41a92e8f51d6f6da5b840f3364474d6aaba.tar.bz2
rails-f22bc41a92e8f51d6f6da5b840f3364474d6aaba.zip
Include default headers by default in API mode
ActionDispatch's default headers are now moved into their own module that are by default included in both Base and API. This allows API-mode applications to take advantage of the default security headers, as well as providing an easy way to add more.
Diffstat (limited to 'actionpack/lib/action_controller/metal/default_headers.rb')
-rw-r--r--actionpack/lib/action_controller/metal/default_headers.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/metal/default_headers.rb b/actionpack/lib/action_controller/metal/default_headers.rb
new file mode 100644
index 0000000000..eef0602fcd
--- /dev/null
+++ b/actionpack/lib/action_controller/metal/default_headers.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module ActionController
+ # Allows configuring default headers that will be automatically merged into
+ # each response.
+ module DefaultHeaders
+ extend ActiveSupport::Concern
+
+ module ClassMethods
+ def make_response!(request)
+ ActionDispatch::Response.create.tap do |res|
+ res.request = request
+ end
+ end
+ end
+ end
+end