mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Always ask for a header argument in ResquestId middleware
This commit is contained in:
parent
2711dcc9a6
commit
5087d00153
3 changed files with 5 additions and 4 deletions
|
@ -15,9 +15,9 @@ module ActionDispatch
|
||||||
# The unique request id can be used to trace a request end-to-end and would typically end up being part of log files
|
# The unique request id can be used to trace a request end-to-end and would typically end up being part of log files
|
||||||
# from multiple pieces of the stack.
|
# from multiple pieces of the stack.
|
||||||
class RequestId
|
class RequestId
|
||||||
def initialize(app, header: nil)
|
def initialize(app, header:)
|
||||||
@app = app
|
@app = app
|
||||||
@header = header || "X-Request-Id"
|
@header = header
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
|
|
|
@ -23,6 +23,7 @@ module ActionDispatch
|
||||||
config.action_dispatch.use_authenticated_cookie_encryption = false
|
config.action_dispatch.use_authenticated_cookie_encryption = false
|
||||||
config.action_dispatch.use_cookies_with_metadata = false
|
config.action_dispatch.use_cookies_with_metadata = false
|
||||||
config.action_dispatch.perform_deep_munge = true
|
config.action_dispatch.perform_deep_munge = true
|
||||||
|
config.action_dispatch.request_id_header = "X-Request-Id"
|
||||||
|
|
||||||
config.action_dispatch.default_headers = {
|
config.action_dispatch.default_headers = {
|
||||||
"X-Frame-Options" => "SAMEORIGIN",
|
"X-Frame-Options" => "SAMEORIGIN",
|
||||||
|
|
|
@ -33,7 +33,7 @@ class RequestIdTest < ActiveSupport::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def stub_request(env = {}, header: nil)
|
def stub_request(env = {}, header: "X-Request-Id")
|
||||||
ActionDispatch::RequestId.new(lambda { |environment| [ 200, environment, [] ] }, header: header).call(env)
|
ActionDispatch::RequestId.new(lambda { |environment| [ 200, environment, [] ] }, header: header).call(env)
|
||||||
ActionDispatch::Request.new(env)
|
ActionDispatch::Request.new(env)
|
||||||
end
|
end
|
||||||
|
@ -68,7 +68,7 @@ class RequestIdResponseTest < ActionDispatch::IntegrationTest
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def with_test_route_set(header: nil)
|
def with_test_route_set(header: "X-Request-Id")
|
||||||
with_routing do |set|
|
with_routing do |set|
|
||||||
set.draw do
|
set.draw do
|
||||||
get "/", to: ::RequestIdResponseTest::TestController.action(:index)
|
get "/", to: ::RequestIdResponseTest::TestController.action(:index)
|
||||||
|
|
Loading…
Reference in a new issue