Sha256: 7995349f90c63ff37b761a9d94b530f5dda22e39700e1f0332a9196a2a1a8c31
Contents?: true
Size: 1.25 KB
Versions: 3
Compression:
Stored size: 1.25 KB
Contents
class HooksController < ApplicationController skip_before_filter :verify_authenticity_token # https://developer.github.com/webhooks/#events EVENT_HANDLERS = { "pull_request" => Github::PullRequestEvent, "push" => Github::PostReceiveEvent, "commit_comment" => Github::CommitCommentEvent, "issue_comment" => Github::IssueCommentEvent, "pull_request_review_comment" => Github::DiffCommentEvent }.freeze 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 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, params: payload head 200 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
houston-core-0.8.0.pre | app/controllers/hooks_controller.rb |
houston-core-0.7.0 | app/controllers/hooks_controller.rb |
houston-core-0.7.0.beta4 | app/controllers/hooks_controller.rb |