Sha256: ace70d164529b3340d2edbe39d88181520ff2b1921e1ac86c47b753d2685e36b
Contents?: true
Size: 977 Bytes
Versions: 24
Compression:
Stored size: 977 Bytes
Contents
# frozen_string_literal: true class Rack::App::Router::Tree::Vein < ::Hash def set(env) app = create_app(env) request_methods(env).each do |request_method| self[request_method.to_s.upcase] = app end end def call(env) app = app_by(env) app && app.call(env) end protected def app_by(env) self[env[Rack::App::Constants::ENV::REQUEST_METHOD]] end def create_app(env) app = env.endpoint.to_app env.params.empty? ? app : wrap(app, env.params) end def wrap(app, params) builder = Rack::Builder.new builder.use(Rack::App::Middlewares::SetPathParams, params) builder.run(app) builder.to_app end def request_methods(env) request_method = env.endpoint.request_method case request_method || raise('missing config: request_methods') when Rack::App::Constants::HTTP::METHOD::ANY Rack::App::Constants::HTTP::METHODS else [request_method].flatten.map(&:to_sym) end end end
Version data entries
24 entries across 24 versions & 1 rubygems