Class: Rack::GithubWebhooks
- Inherits:
-
Object
- Object
- Rack::GithubWebhooks
- Defined in:
- lib/rack/github_webhooks.rb,
lib/rack/github_webhooks/version.rb
Defined Under Namespace
Classes: Signature
Constant Summary collapse
- VERSION =
'0.3.0'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, opts = {}) ⇒ GithubWebhooks
constructor
A new instance of GithubWebhooks.
Constructor Details
#initialize(app, opts = {}) ⇒ GithubWebhooks
Returns a new instance of GithubWebhooks.
24 25 26 27 |
# File 'lib/rack/github_webhooks.rb', line 24 def initialize(app, opts = {}) @app = app @secret = opts[:secret] end |
Instance Method Details
#call(env) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rack/github_webhooks.rb', line 29 def call(env) env['rack.input'].rewind signature = Signature.new( @secret, env['HTTP_X_HUB_SIGNATURE'], env['rack.input'].read ) return [400, {}, ["Signatures didn't match!"]] unless signature.valid? @app.call(env) end |