Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add website routing rules api & tests & example #194

Merged
merged 1 commit into from
Jul 4, 2019

Conversation

liyanzhang505
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


LYZ seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

oss2/models.py Outdated
"""匹配规则之后执行的动作

:父节点: class `RoutingRule <oss2.models.RoutingRule>`
:param proto: 跳转时的协议,只能取值为http或者https。当RedirectType为External或者AliCDN时需要指定。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redirect 里面的参数说明,先罗列共性部分,然后再根据redirecttype 罗列。

oss2/models.py Outdated
:param mirror_url_slave: 镜像回源的备站地址,只有在RedirectType为Mirror时有意义
:type mirror_url_slave: str

:param mirror_url_probe: 镜像回源的主站地址,mirror_url_slave指定试,此项必须指定
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个参数的说明不准确。

oss2/models.py Outdated
:param mirror_headers: 指定匹配此规则后执行的动作
:type mirror_headers: class:`RedirectMirrorHeaders <oss2.models.RedirectMirrorHeaders>`

:param mirror_multi_alternates: 指定匹配此规则后执行的动作
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这部分先删掉。

oss2/models.py Outdated
if (not mirror_url_slave.startswith('http://') and not mirror_url_slave.startswith('https://')) or not mirror_url_slave.endswith('/'):
raise ClientError(r'mirror_url_salve is invalid, should startwith "http://" or "https://", and endwith "/"')

if any((proto, host_name, replace_key_with, replace_key_prefix_with, http_redirect_code)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个判断语句可以拿掉。在构建xml的时候,根据type 设置 相关的参数即可。

return mirror_multi_alternates

def parse_routing_rule_redirect(redirect_node):
redirect_type = _find_tag(redirect_node, 'RedirectType')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在parser xml的时候,可以根据 type parser 相关的 数据。不相关的可以忽略掉。

_add_text_child(error_node, 'Key', bucket_websiste.error_file)
_add_text_child(error_node, 'Key', bucket_website.error_file)

rules_node = ElementTree.SubElement(root, "RoutingRules")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

构建 RoutingRules 节点的时候,先判断rule 的数量,如果为空,则不需要构建该节点。

oss2/xml_utils.py Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jul 1, 2019

Coverage Status

Coverage decreased (-1.1%) to 32.76% when pulling 77a98a9 on liyanzhang505:dev-website-routing into dbbb317 on aliyun:dev-1907.

@huiguangjun huiguangjun merged commit 5a7316d into aliyun:dev-1907 Jul 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants