-
Notifications
You must be signed in to change notification settings - Fork 363
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
Conversation
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时需要指定。 |
There was a problem hiding this comment.
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指定试,此项必须指定 |
There was a problem hiding this comment.
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: 指定匹配此规则后执行的动作 |
There was a problem hiding this comment.
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)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个判断语句可以拿掉。在构建xml的时候,根据type 设置 相关的参数即可。
oss2/xml_utils.py
Outdated
return mirror_multi_alternates | ||
|
||
def parse_routing_rule_redirect(redirect_node): | ||
redirect_type = _find_tag(redirect_node, 'RedirectType') |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
构建 RoutingRules 节点的时候,先判断rule 的数量,如果为空,则不需要构建该节点。
cd4fa5b
to
7128e8f
Compare
7128e8f
to
2ddd84f
Compare
2ddd84f
to
77a98a9
Compare
No description provided.