lib/rack/app/endpoint/builder.rb in rack-app-5.12.0 vs lib/rack/app/endpoint/builder.rb in rack-app-6.0.0
- old
+ new
@@ -1,21 +1,30 @@
-require "rack/builder"
+# frozen_string_literal: true
+require 'rack/builder'
class Rack::App::Endpoint::Builder
-
def initialize(config)
@config = config
end
def build
builder = Rack::Builder.new
apply_middleware_build_blocks(builder)
- builder.run(Rack::App::Endpoint::Executor.new(@config))
+ builder.run(app)
builder.to_app
end
protected
+ def app
+ case @config.type
+ when :endpoint
+ Rack::App::Endpoint::Executor.new(@config)
+ else
+ @config.callable
+ end
+ end
+
def apply_middleware_build_blocks(builder)
builder_blocks.each do |builder_block|
builder_block.call(builder)
end
builder.use(Rack::App::Middlewares::Configuration, @config)
@@ -30,9 +39,8 @@
builder.use(Rack::App::Middlewares::Hooks::After, after_block)
end
end
def builder_blocks
- [@config.app_class.middlewares, @config.middleware_builders_blocks].flatten
+ [@config.app_class.middlewares, @config.endpoint_specific_middlewares].flatten
end
-
end