Class: Gris::Application

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Configurable
Defined in:
lib/gris/application.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



8
9
10
11
# File 'lib/gris/application.rb', line 8

def initialize
  Gris::Deprecations.initialization_checks
  @filenames = ['', '.html', 'index.html', '/index.html']
end

Class Method Details

.instance(config = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gris/application.rb', line 13

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

Instance Method Details

#call(env) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/gris/application.rb', line 26

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