Class: Rack::GithubWebhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/github_webhooks.rb,
lib/rack/github_webhooks/version.rb

Constant Summary collapse

HMAC_DIGEST =
OpenSSL::Digest.new('sha1')
VERSION =
'0.1.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ GithubWebhooks

Returns a new instance of GithubWebhooks.



13
14
15
16
# File 'lib/rack/github_webhooks.rb', line 13

def initialize(app, opts = {})
  @app = app
  @secret = opts[:secret]
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



9
10
11
# File 'lib/rack/github_webhooks.rb', line 9

def app
  @app
end

#requestObject (readonly)

Returns the value of attribute request.



11
12
13
# File 'lib/rack/github_webhooks.rb', line 11

def request
  @request
end

#secretObject (readonly)

Returns the value of attribute secret.



10
11
12
# File 'lib/rack/github_webhooks.rb', line 10

def secret
  @secret
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
# File 'lib/rack/github_webhooks.rb', line 18

def call(env)
  @request = Rack::Request.new(env)
  return [400, {}, ["Signatures didn't match!"]] unless signature_valid?
  app.call(env)
end