Skip to content

Commit def0d1c

Browse files
committed
Use duck-typing to detect request object
ActionDispatch::Requests includes Rack::Request::Env and Rack::Request::Helpers which gives access to both of these methods. Fixes #105
1 parent 4bfbd00 commit def0d1c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/pusher/webhook.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class WebHook
3030
#
3131
def initialize(request, client = Pusher)
3232
@client = client
33-
# Should work without Rack
34-
if defined?(Rack::Request) && request.kind_of?(Rack::Request)
33+
# For Rack::Request and ActionDispatch::Request
34+
if request.respond_to?(:env) && request.respond_to?(:content_type)
3535
@key = request.env['HTTP_X_PUSHER_KEY']
3636
@signature = request.env["HTTP_X_PUSHER_SIGNATURE"]
3737
@content_type = request.content_type

0 commit comments

Comments
 (0)