Last active
August 29, 2015 14:06
-
-
Save swalberg/9bc2e2680afb6762cc06 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Inside the gem | |
| class ActionController::Base | |
| def self.check_webhook_signature(key, *args) | |
| before_filter lambda { |controller| controller.check_webhook_signature(key, controller)}, *args | |
| end | |
| def check_webhook_signature(key, controller) | |
| # Do the work | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Gem was included through Gemfile | |
| class WebhookController < ApplicationController | |
| # Gem provides a Class method to ActionController::Base that inserts a before_action | |
| check_webhook_signature "MyKey" | |
| def index | |
| # I can do my thing here | |
| end | |
| end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Pros:
Cons: