class Rack::EsaWebhooks
Constants
- VERSION
Public Class Methods
new(app, opts = {})
click to toggle source
# File lib/rack/esa_webhooks.rb, line 23 def initialize(app, opts = {}) @app = app @secret = opts[:secret] end
Public Instance Methods
call(env)
click to toggle source
# File lib/rack/esa_webhooks.rb, line 28 def call(env) rewind_body(env) signature = Signature.new( @secret, env['HTTP_X_ESA_SIGNATURE'], env['rack.input'].read ) return [400, {}, ["Signatures didn't match!"]] unless signature.valid? rewind_body(env) @app.call(env) end
Private Instance Methods
rewind_body(env)
click to toggle source
# File lib/rack/esa_webhooks.rb, line 43 def rewind_body(env) env['rack.input'].rewind if env['rack.input'].respond_to?(:rewind) rescue Errno::ESPIPE end