mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
introduce default_headers config
This commit is contained in:
parent
2da242f63c
commit
2a290f7f7c
3 changed files with 11 additions and 0 deletions
|
@ -58,6 +58,7 @@ module ActionDispatch # :nodoc:
|
|||
LOCATION = "Location".freeze
|
||||
|
||||
cattr_accessor(:default_charset) { "utf-8" }
|
||||
cattr_accessor(:default_headers)
|
||||
|
||||
include Rack::Response::Helpers
|
||||
include ActionDispatch::Http::Cache::Response
|
||||
|
@ -96,6 +97,10 @@ module ActionDispatch # :nodoc:
|
|||
def initialize(status = 200, header = {}, body = [])
|
||||
super()
|
||||
|
||||
if self.class.default_headers.respond_to?(:merge)
|
||||
header = self.class.default_headers.merge(header)
|
||||
end
|
||||
|
||||
self.body, self.header, self.status = body, header, status
|
||||
|
||||
@sending_file = false
|
||||
|
|
|
@ -23,6 +23,7 @@ module ActionDispatch
|
|||
ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
|
||||
ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
|
||||
ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding
|
||||
ActionDispatch::Response.default_headers = app.config.action_dispatch.default_headers
|
||||
|
||||
ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses)
|
||||
ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates)
|
||||
|
|
|
@ -41,6 +41,11 @@ module <%= app_const_base %>
|
|||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
config.filter_parameters += [:password]
|
||||
|
||||
config.action_dispatch.default_headers = {
|
||||
'X-Frame-Options' => 'SAMEORIGIN',
|
||||
'X-XSS-Protection' => '1; mode=block'
|
||||
}
|
||||
|
||||
# Use SQL instead of Active Record's schema dumper when creating the database.
|
||||
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
||||
# like if you have constraints or database-specific column types.
|
||||
|
|
Loading…
Reference in a new issue