Sha256: 38e860895969e5d94cf0f3cb6332c167724bc1919d495dfc8de2780d1808f41d

Contents?: true

Size: 799 Bytes

Versions: 3

Compression:

Stored size: 799 Bytes

Contents

require 'active_support/configurable'

module Gris
  class Application
    include ActiveSupport::Configurable
    config_accessor :use_health_middleware

    def self.instance(config = {})
      @instance ||= Rack::Builder.new do
        use Gris::Middleware::Health unless config[:use_health_middleware] == false
        use Rack::Cors do
          allow do
            origins '*'
            resource '*', headers: :any, methods: :get
          end
        end
        run Gris::Application.new
      end.to_app
    end

    def call(env)
      response = ApplicationEndpoint.call(env)
      case response[0]
      when 404, 500
        body = { code: response[0], message: response[2] }.to_json
        [response[0], response[1], [body]]
      else
        response
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gris-0.5.2 lib/gris/application.rb
gris-0.5.1 lib/gris/application.rb
gris-0.5.0 lib/gris/application.rb