Skip to content

Commit 61cc148

Browse files
committed
Add comment re each/call
which - it would seem - requires another conditional, but it doesn't.
1 parent ee1eba2 commit 61cc148

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/appsignal/rack/body_wrapper.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ def self.wrap(original_body, appsignal_transaction)
2525
elsif original_body.respond_to?(:to_ary)
2626
ArrayableBodyWrapper.new(original_body, appsignal_transaction)
2727
elsif !original_body.respond_to?(:each) && original_body.respond_to?(:call)
28-
CallableBodyWrapper.new(original_body, appsignal_transaction)
28+
# This body only supports #call, so we must be running a Rack 3 application
29+
# It is possible that a body exposes both `each` and `call` in the hopes of
30+
# being backwards-compatible with both Rack 3.x and Rack 2.x, however
31+
# this is not going to work since the SPEC says that if both are available,
32+
# `each` should be used and `call` should be ignored.
33+
# So for that case we can drop by to our default EnumerableBodyWrapper
34+
CallableBodyWrapper.new(original_body, appsignal_transaction_or_nil)
2935
else
3036
EnumerableBodyWrapper.new(original_body, appsignal_transaction)
3137
end

0 commit comments

Comments
 (0)