Class: Proscenium::Middleware
- Extended by:
- ActiveSupport::Autoload
- Defined in:
- lib/proscenium/middleware.rb,
lib/proscenium/middleware/base.rb,
lib/proscenium/middleware/engines.rb,
lib/proscenium/middleware/esbuild.rb,
lib/proscenium/middleware/runtime.rb
Defined Under Namespace
Classes: Base, BuildError, Engines, Esbuild, Runtime
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
15 16 17 18 19 20 21 |
# File 'lib/proscenium/middleware.rb', line 15 def initialize(app) @app = app chunks_path = Rails.public_path.join('assets').to_s headers = Rails.application.config.public_file_server.headers || {} @chunk_handler = ::ActionDispatch::FileHandler.new(chunks_path, headers:) end |
Instance Method Details
#call(env) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/proscenium/middleware.rb', line 23 def call(env) request = Rack::Request.new(env) return @app.call(env) if !request.get? && !request.head? return @chunk_handler.attempt(request.env) if request.path.match?(%r{^/_asset_chunks/}) attempt(request) || @app.call(env) end |