Module: Jets::Application::Middleware

Included in:
Jets::Application
Defined in:
lib/jets/application/middleware.rb

Instance Method Summary collapse

Instance Method Details

#assemble_appObject



14
15
16
17
18
19
20
21
22
# File 'lib/jets/application/middleware.rb', line 14

def assemble_app
  Rack::Builder.new do
    map("/") do
      use Jets::Server::TimingMiddleware
      use Webpacker::DevServerProxy if Jets.webpacker?
      run Jets::Server
    end
  end
end

#call(env) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/jets/application/middleware.rb', line 2

def call(env)
  # Only require when necessary because middleware is only used for development
  # Requring here instead of top of file because Jets::Application::Middleware
  # gets autoloaded when Jets::Application gets autoloaded.
  # Trying to keep the config.ru interface clean:
  #
  #   require "jets"
  #   run Jets.application
  require "jets/server/webpacker_setup" if Jets.webpacker? # makes "use Webpacker::DevServerProxy" works
  triplet = assemble_app.call(env)
end