Skip to content

Commit 4a021df

Browse files
bdewater-thatchgrzuy
authored andcommitted
Inherit Request class from ActionDispatch if available
1 parent b2ebab9 commit 4a021df

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/rack/attack/request.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

3-
# Rack::Attack::Request is the same as ::Rack::Request by default.
3+
# Rack::Attack::Request is the same as :ActionDispatch::Request in Rails apps,
4+
# and ::Rack::Request in other apps by default.
45
#
56
# This is a safe place to add custom helper methods to the request object
67
# through monkey patching:
@@ -15,7 +16,7 @@
1516
#
1617
module Rack
1718
class Attack
18-
class Request < ::Rack::Request
19+
class Request < defined?(::ActionDispatch::Request) ? ::ActionDispatch::Request : ::Rack::Request
1920
end
2021
end
2122
end

0 commit comments

Comments
 (0)