Sha256: 2f07e8555cb7fbc49a75592bf6e463c7751f1371a582f8621cc88cdf485fedb9
Contents?: true
Size: 1.1 KB
Versions: 6
Compression:
Stored size: 1.1 KB
Contents
# 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(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) @config.middlewares.each do |builder_block| builder_block.call(builder) end builder.use(Rack::App::Middlewares::Configuration, @config) apply_hook_middlewares(builder) end def apply_hook_middlewares(builder) if @config.app_class.before.length + @config.app_class.after.length > 0 builder.use(Rack::App::Endpoint::Catcher, @config) end @config.app_class.before.each do |before_block| builder.use(Rack::App::Middlewares::Hooks::Before, before_block) end @config.app_class.after.each do |after_block| builder.use(Rack::App::Middlewares::Hooks::After, after_block) end end end
Version data entries
6 entries across 6 versions & 1 rubygems