def match(self, req): path = url_unquote(req.path) LOG.debug("Match path: %s", path) if len(path) > 1 and path.endswith('/'): path = path[:-1] match = self.routes.match(path, req.environ) if match is None: raise NotFoundException('No route matches "%s" path' % req.path) # To account for situation when match may return multiple values try: path_vars = match[0] except KeyError: path_vars = match path_vars = dict(path_vars) path = path_vars.pop('_api_path') method = path_vars.pop('_api_method') endpoint = self.spec['paths'][path][method] return endpoint, path_vars