Sha256: ff8084a234a6a132b5b4391f98e54aacc95e6d600a33aa58deb4e41998f41165

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

module Cloudfuji
  class EnvsController < ApplicationController
    # PUT /cloudfuji/envs/:id
    def update
      if ENV["CLOUDFUJI_APP_KEY"] != params[:key] or params[:id] == "CLOUDFUJI_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 => :unprocessable_entity }
        end

      else

        var = params[:id].upcase

        ENV[var] = params[:value]
        @value = ENV[var]
        
        respond_to do |format|
          if @value != ENV[var]
            format.html{render :layout => false, :text => true, :status => :unprocessable_entity}
            format.json{render :status => :unprocessable_entity}
          else
            Cloudfuji::Data.fire(var, {var => ENV[var]})
            format.html{render :text => true}
            format.json{render :json => {var => ENV[var]}}
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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