def get_restful_params(urlstring):
"""Returns a dictionary of paired RESTful URI parameters"""
parsed_path = urlparse(urlstring.strip("/"))
tokens = parsed_path.path.split('/')
# Be sure we at least have /v#/opt
if len(tokens) < 2:
return None
# Be sure first token is API version
if len(tokens[0]) == 2 and tokens[0][0] == 'v':
params = list_to_dict(tokens[1:])
params["api_version"] = tokens[0][1]
return params
else:
return None
评论列表
文章目录