Sha256: 59c606e5ff46f2aa542e0fcecf5da57d9d9c157a86cc9d19a22bd89e75661172

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

module Cloudfuji
  class DataController < ApplicationController
    
    # POST /cloudfuji/data/
    def index
      @key = params.delete("key")

      if ENV["CLOUDFUJI_APP_KEY"] != @key
        respond_to do |format|
          format.html { render :layout => false, :text => true, :status => :forbidden }
          format.json { render :json => {:error => "Not authorized to submit data to this app" }, :status => 401 }
        end

        return
      end
      
      puts "Idobus Data rec'd: #{params.inspect}"
      puts params["category"].inspect

      hook_data             = {}
      hook_data["category"] = params["category"]
      hook_data["event"]    = params["event"]
      hook_data["data"]     = params["data"]

      puts "Firing with: #{hook_data.inspect}"
      event = "#{params['category']}.#{params['event']}".gsub('.', '_').to_sym

      Cloudfuji::Data.fire(hook_data, event)

      respond_to do |format|
        format.json {render :json => {'acknowledged' => true}, :status => 200}
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cloudfuji-0.0.46 app/controllers/cloudfuji/data_controller.rb
cloudfuji-0.0.45 app/controllers/cloudfuji/data_controller.rb
cloudfuji-0.0.44 app/controllers/cloudfuji/data_controller.rb
cloudfuji-0.0.43 app/controllers/cloudfuji/data_controller.rb
cloudfuji-0.0.42 app/controllers/cloudfuji/data_controller.rb
cloudfuji-0.0.41 app/controllers/cloudfuji/data_controller.rb
cloudfuji-0.0.40 app/controllers/cloudfuji/data_controller.rb
cloudfuji-0.0.39 app/controllers/cloudfuji/data_controller.rb