<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dispatch(environ, start_response, mapper):
 """Find a matching route for the current request. :raises: 404(not found) if no match request 405(method not allowed) if route exist but method not provided. """

    result = mapper.match(environ=environ)
    if result is None:
        info = environ.get('PATH_INFO', '')
        LOG.debug('The route for %s can not be found', info)
        raise webob.exc.HTTPNotFound(
            json_formatter=util.json_error_formatter)

    handler = result.pop('action')

    environ['wsgiorg.routing_args'] = ((), result)
    return handler(environ, start_response)