Class: HooksController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- HooksController
- Defined in:
- app/controllers/hooks_controller.rb
Constant Summary collapse
- EVENT_HANDLERS =
{ "pull_request" => Github::PullRequestEvent, "push" => Github::PostReceiveEvent, "commit_comment" => Github::CommitCommentEvent, "issue_comment" => Github::IssueCommentEvent, "pull_request_review_comment" => Github::DiffCommentEvent }.freeze
Instance Method Summary collapse
Methods inherited from ApplicationController
#after_sign_in_path_for, #api_authenticate!, #current_project, #expire_revision!, #followed_projects, #no_cache, #read_revision, #require_login, #return_or_cache_revision!, #revision, #save_current_project, #set_current_project, #unfurling?
Methods included from UrlHelper
#feature_path, #github_commit_range_url, #github_commit_url, #github_project_url, #github_url?, #goldmine_case_number_url, #link_to_project_feature, #new_release_url, #releases_path
Instance Method Details
#github ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/hooks_controller.rb', line 13 def github event = request.headers["X-GitHub-Event"] if event == "ping" Rails.logger.info "\e[32m[github] ping received\e[0m" head 200 elsif event_processor = EVENT_HANDLERS[event] payload = params.fetch "hook" event_processor.process! payload head 200 else Rails.logger.warn "\e[33m[github] Unrecognized event: #{event}\e[0m" head 404 end end |
#trigger ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/hooks_controller.rb', line 31 def trigger event = "hooks:#{params[:hook]}" unless Houston.observer.observed?(event) render text: "A hook with the slug '#{params[:hook]}' is not defined", status: 404 return end payload = params.except(:action, :controller).merge({ sender: { ip: request.remote_ip, agent: request.user_agent } }) Houston.observer.fire event, payload head 200 end |