railtie.rb 1.6 KB
Newer Older
1 2 3 4
require "action_dispatch"

module ActionDispatch
  class Railtie < Rails::Railtie
5
    config.action_dispatch = ActiveSupport::OrderedOptions.new
6
    config.action_dispatch.x_sendfile_header = nil
C
Carlhuda 已提交
7
    config.action_dispatch.ip_spoofing_check = true
8
    config.action_dispatch.show_exceptions = true
9
    config.action_dispatch.best_standards_support = true
10
    config.action_dispatch.tld_length = 1
11
    config.action_dispatch.ignore_accept_header = false
12 13
    config.action_dispatch.rescue_templates = { }
    config.action_dispatch.rescue_responses = { }
14
    config.action_dispatch.default_charset = nil
15 16 17 18

    config.action_dispatch.rack_cache = {
      :metastore => "rails:/",
      :entitystore => "rails:/",
19
      :verbose => false
20 21
    }

22 23
    initializer "action_dispatch.configure" do |app|
      ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
24
      ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
25
      ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding
E
Egor Homakov 已提交
26
      ActionDispatch::Response.default_headers = app.config.action_dispatch.default_headers
L
lest 已提交
27

28 29
      ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses)
      ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates)
30

L
lest 已提交
31 32
      config.action_dispatch.always_write_cookie = Rails.env.development? if config.action_dispatch.always_write_cookie.nil?
      ActionDispatch::Cookies::CookieJar.always_write_cookie = config.action_dispatch.always_write_cookie
33 34

      ActionDispatch.test_app = app
35
    end
36
  end
37
end