Class: Gris::Application
- Inherits:
-
Object
- Object
- Gris::Application
- Includes:
- ActiveSupport::Configurable
- Defined in:
- lib/gris/application.rb,
lib/gris/application/configuration.rb
Defined Under Namespace
Classes: Configuration
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize ⇒ Application
constructor
A new instance of Application.
Constructor Details
#initialize ⇒ Application
Returns a new instance of Application.
8 9 10 11 12 13 14 15 16 |
# File 'lib/gris/application.rb', line 8 def initialize Gris::Deprecations.initialization_checks @filenames = ['', '.html', 'index.html', '/index.html'] @rack_static = ::Rack::Static.new( -> { [404, {}, []] }, root: File.('../public', __FILE__), urls: ['/'] ) end |
Class Method Details
.instance(config = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gris/application.rb', line 18 def self.instance(config = {}) @instance ||= Rack::Builder.new do use ActiveRecord::ConnectionAdapters::ConnectionManagement 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
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gris/application.rb', line 32 def call(env) response = ApplicationEndpoint.call(env) # Render error pages or return API response case response[0] when 404, 500 content = @rack_static.call(env.merge('PATH_INFO' => "/errors/#{response[0]}.html")) [response[0], content[1], content[2]] else response end end |