Sha256: 58e8fe74633bad7e4fd623131ac9c93ae166868e68f44f8d91ba27a2136cca91

Contents?: true

Size: 1.7 KB

Versions: 32

Compression:

Stored size: 1.7 KB

Contents

module ZuoraConnect
  class StaticController < ApplicationController
    before_filter :authenticate_connect_app_request, :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
    before_filter :clear_connect_app_session,        :only =>   [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
    after_filter :persist_connect_app_session,       :except => [:metrics, :health, :session_error, :invalid_app_instance_error, :initialize_app]
    
    skip_before_filter :verify_authenticity_token, :only => [:initialize_app]

    def session_error
      respond_to do |format|
        format.html
        format.json { render json: { message: "Session Error", status: 500 }, status: 500 }
      end
    end

    def invalid_app_instance_error
      respond_to do |format|
        format.html
        format.json {render json: { message: "Invalid App Instance", status: 500 }, status: 500 }
      end
    end

    def metrics
      type = params[:type].present? ? params[:type] : "versions"
      render json: ZuoraConnect::AppInstance.get_metrics(type).to_json, status: 200
    end

    def health
      render json: {
        message: "Alive",
        status: 200
      }, status: 200
    end

    def initialize_app
      begin
        authenticate_connect_app_request
        render json: {
          message: "Success",
          status: 200
        }, status: 200
      rescue
        render json: {
          message: "Failure initializing app instance",
          status: 400
        }, status: 400
      end
    end

    private

    def clear_connect_app_session
      Thread.current[:appinstance] = nil
      request.session_options[:skip] = true
    end

  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
zuora_connect-1.7.53 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.52 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.51 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.50 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.49 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.48 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.47 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.46 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.45 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.44 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.43 app/controllers/zuora_connect/static_controller.rb
zuora_connect-1.7.42 app/controllers/zuora_connect/static_controller.rb