lib/hanami/router.rb in hanami-router-2.0.0.alpha2 vs lib/hanami/router.rb in hanami-router-2.0.0.alpha3

- old
+ new

@@ -69,11 +69,11 @@ @block_context = block_context @fixed = {} @variable = {} @globbed = {} @mounted = {} - instance_eval(&blk) + instance_eval(&blk) if blk end # Resolve the given Rack env to a registered endpoint and invokes it. # # @param env [Hash] a Rack env @@ -629,17 +629,17 @@ end # @since 2.0.0 # @api private def not_allowed(env) - (_not_allowed_fixed(env) || _not_allowed_variable(env)) and return NOT_ALLOWED + (_not_allowed_fixed(env) || _not_allowed_variable(env)) and return [405, { "Content-Length" => "11" }, ["Not Allowed"]] end # @since 2.0.0 # @api private def not_found - NOT_FOUND + [404, { "Content-Length" => "9" }, ["Not Found"]] end protected # Fabricate Rack env for the given Rack env, path or named route @@ -664,11 +664,11 @@ when ::Symbol begin url = path(env, params) return env_for(url, params, options) # rubocop:disable Style/RedundantReturn rescue Hanami::Router::InvalidRouteException - EMPTY_RACK_ENV.dup + {} # Empty Rack env end else env end end @@ -691,32 +691,16 @@ # @api private DEFAULT_REDIRECT_CODE = 301 # @since 2.0.0 # @api private - NOT_FOUND = [404, { "Content-Length" => "9" }, ["Not Found"]].freeze - - # @since 2.0.0 - # @api private - NOT_ALLOWED = [405, { "Content-Length" => "11" }, ["Not Allowed"]].freeze - - # @since 2.0.0 - # @api private PARAMS = "router.params" # @since 2.0.0 # @api private - EMPTY_PARAMS = {}.freeze - - # @since 2.0.0 - # @api private - EMPTY_RACK_ENV = {}.freeze - - # @since 2.0.0 - # @api private def lookup(env) endpoint = fixed(env) - return [endpoint, EMPTY_PARAMS] if endpoint + return [endpoint, {}] if endpoint variable(env) || globbed(env) || mounted(env) end # @since 2.0.0