def url_resource(resource):
url = resource.get('url')
if url is None:
return url
if not url:
return None
if callable(url):
return url(resource)
if isinstance(url, six.string_types):
return url
params = resource.get('url_params', {})
params['_external'] = params.get('_external', True)
try:
url = url_for(
resource['endpoints'][0],
**params
)
except BuildError:
url = None
return url
评论列表
文章目录