diff options
| author | Stormwind <stormwind@stormwinds-page.de> | 2012-12-22 20:00:34 +0100 | 
|---|---|---|
| committer | Stormwind <stormwind@stormwinds-page.de> | 2012-12-22 20:00:34 +0100 | 
| commit | ca2273e700e65b3d035f47042314ebcbfc9fd220 (patch) | |
| tree | 51d86ddc663556cd9787294ca08c41878bf2ba7c /lib | |
| parent | 96f2b7a6c44c246a3cb3418de4a893526236ba45 (diff) | |
| parent | 5057a8df4561b3212f2f349c022ee9361a83e1c6 (diff) | |
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/zero/router.rb | 12 | 
1 files changed, 8 insertions, 4 deletions
| diff --git a/lib/zero/router.rb b/lib/zero/router.rb index 5f77624..8d1273f 100644 --- a/lib/zero/router.rb +++ b/lib/zero/router.rb @@ -21,6 +21,10 @@ module Zero      VARIABLE_MATCH = %r{:(\w+)[^/]?}      # the replacement string to make it an regex      VARIABLE_REGEX = '(?<\1>.+?)' +    # environment key to store custom parameters +    ENV_KEY_CUSTOM = 'zero.params.custom' +    # environment key to the path info +    ENV_KEY_PATH_INFO = 'PATH_INFO'      # create a new router instance      # @@ -47,14 +51,14 @@ module Zero      # @param env [Hash] a rack environment      # @return [Array] a rack compatible response      def call(env) -      request = Zero::Request.new(env) +      env[ENV_KEY_CUSTOM] ||= {}        @routes.each do |route, target| -        match = route.match(request.path) +        match = route.match(env[ENV_KEY_PATH_INFO])          if match            match.names.each_index do |i| -            request.params[match.names[i]] = match.captures[i] +            env[ENV_KEY_CUSTOM][match.names[i]] = match.captures[i]            end -          return target.call(request.env) +          return target.call(env)          end        end        [404, {'Content-Type' => 'text/html'}, ['Not found!']] | 
