Sha256: 74201861c8672a88dd848bb3cf08fb02075ad579a14c5de4898c9c6fc5980439

Contents?: true

Size: 759 Bytes

Versions: 1

Compression:

Stored size: 759 Bytes

Contents

class ProjectHooksController < ApplicationController
  skip_before_filter :verify_authenticity_token
  
  
  def trigger
    project = Project.find_by_slug(params[:project_id])
    unless project
      render text: "A project with the slug '#{params[:project_id]}' could not be found", status: 404
      return
    end
    
    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, project, payload
    head 200
  end
  
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
houston-core-0.5.0.beta1 app/controllers/project_hooks_controller.rb