def __call__(self, environ, start_response): """ Makes object of the Router class callables as specified by the WSGI spceification Args: environ: (dict): The WSGI environment dict start_response: (callable): The WSGI response callable """ req = Request(environ) for regex, method, app, vars in self.routes: match = regex.match(req.path_info) if match and req.method == method: req.urlvars = match.groupdict() if hasattr(req, 'extras'): req.extras.update(vars) else: req.extras = vars return app(environ, start_response) error = exc.HTTPNotFound() return error(environ, start_response)