def parse_endpoint(endpoint):
"""
Convert an endpoint name into an (operation, ns) tuple.
"""
# compute the operation
parts = endpoint.split(".")
operation = Operation.from_name(parts[1])
# extract its parts
matcher = match(operation.endpoint_pattern, endpoint)
if not matcher:
raise InternalServerError("Malformed operation endpoint: {}".format(endpoint))
kwargs = matcher.groupdict()
del kwargs["operation"]
return operation, Namespace(**kwargs)
评论列表
文章目录