def route
      # Sanitize the URI:
      # * Unescape escaped characters
      # * Replace runs of / with a single /
      path_info = Rack::Utils.unescape(request.path_info).gsub(%r{/+}, '/')

      ROUTES.each do |path_matcher, verb, handler|
        path_info.match(path_matcher) do |match|
          @repository_uri = match[1]
          @request_verb = verb

          return method_not_allowed unless verb == request.request_method
          return bad_request if bad_uri?(@repository_uri)

          git.repository_path = root + @repository_uri
          return not_found unless git.exist?

          return send(handler, *match[2..-1])
        end
      end
      not_found
    end
def route
      # Sanitize the URI:
      # * Unescape escaped characters
      # * Replace runs of / with a single /
      path_info = Rack::Utils.unescape(request.path_info).gsub(%r{/+}, '/')

      ROUTES.each do |path_matcher, verb, handler|
        path_info.match(path_matcher) do |match|
          @repository_uri = match[1]
          @request_verb = verb

          return method_not_allowed unless verb == request.request_method
          return bad_request if bad_uri?(@repository_uri)

          git.repository_path = root + @repository_uri
          return not_found unless git.exist?

          return send(handler, *match[2..-1])
        end
      end
      not_found
    end
Routes requests to appropriate handlers.  Performs request path cleanup
 and several sanity checks prior to attempting to handle the request.

 @return a Rack response object.