'Try to find a version first in the accept header, then the URL'

def process_request(self, req):

    args = {'method': req.method, 'path': req.path, 'accept': req.accept}
    LOG.debug('Determining    version    of    request:    %(method)s    %(path)s    Accept:    %(accept)s', args)
    if (req.path_info_peek() == 'versions'):
        return self.versions_app.index(req, explicit=True)
    accept = str(req.accept)
    if accept.startswith(self.vnd_mime_type):
        LOG.debug('Using    media-type    versioning')
        token_loc = len(self.vnd_mime_type)
        req_version = accept[token_loc:]
    else:
        LOG.debug('Using    url    versioning')
        req_version = self._pop_path_info(req)
    try:
        version = self._match_version_string(req_version)
    except ValueError:
        LOG.debug('Unknown    version.    Returning    version    choices.')
        return self.versions_app
    req.environ['api.version'] = version
    req.path_info = ''.join(('/v', str(version), req.path_info))
    LOG.debug('Matched    version:    v%d', version)
    LOG.debug('new    path    %s', req.path_info)
    return None
