update bucket domain and website struct
This commit is contained in:
@@ -8,9 +8,9 @@ import (
|
||||
|
||||
type BucketPutDomainOptions struct {
|
||||
XMLName xml.Name `xml:"DomainConfiguration"`
|
||||
Status string `xml:"DomainRule>Status,omitempty"`
|
||||
Name string `xml:"DomainRule>Name,omitempty"`
|
||||
Type string `xml:"DomainRule>Type,omitempty"`
|
||||
Status string `xml:"DomainRule>Status"`
|
||||
Name string `xml:"DomainRule>Name"`
|
||||
Type string `xml:"DomainRule>Type"`
|
||||
ForcedReplacement string `xml:"DomainRule>ForcedReplacement,omitempty"`
|
||||
}
|
||||
type BucketGetDomainResult BucketPutDomainOptions
|
||||
|
||||
@@ -15,12 +15,24 @@ type WebsiteRoutingRule struct {
|
||||
RedirectReplaceKeyPrefix string `xml:"Redirect>ReplaceKeyPrefixWith,omitempty"`
|
||||
}
|
||||
|
||||
type WebsiteRoutingRules struct {
|
||||
Rules []WebsiteRoutingRule `xml:"RoutingRule,omitempty"`
|
||||
}
|
||||
|
||||
type ErrorDocument struct {
|
||||
Key string `xml:"Key,omitempty"`
|
||||
}
|
||||
|
||||
type RedirectRequestsProtocol struct {
|
||||
Protocol string `xml:"Protocol,omitempty"`
|
||||
}
|
||||
|
||||
type BucketPutWebsiteOptions struct {
|
||||
XMLName xml.Name `xml:"WebsiteConfiguration"`
|
||||
Index string `xml:"IndexDocument>Suffix"`
|
||||
RedirectProtocol string `xml:"RedirectAllRequestsTo>Protocol,omitempty"`
|
||||
Error string `xml:"ErrorDocument>Key,omitempty"`
|
||||
Rules []WebsiteRoutingRule `xml:"RoutingRules>RoutingRule,omitempty"`
|
||||
XMLName xml.Name `xml:"WebsiteConfiguration"`
|
||||
Index string `xml:"IndexDocument>Suffix"`
|
||||
RedirectProtocol *RedirectRequestsProtocol `xml:"RedirectAllRequestsTo,omitempty"`
|
||||
Error *ErrorDocument `xml:"ErrorDocument,omitempty"`
|
||||
RoutingRules *WebsiteRoutingRules `xml:"RoutingRules,omitempty"`
|
||||
}
|
||||
|
||||
type BucketGetWebsiteResult BucketPutWebsiteOptions
|
||||
|
||||
@@ -26,9 +26,6 @@ func TestBucketService_GetWebsite(t *testing.T) {
|
||||
<RedirectAllRequestsTo>
|
||||
<Protocol>https</Protocol>
|
||||
</RedirectAllRequestsTo>
|
||||
<ErrorDocument>
|
||||
<Key>Error.html</Key>
|
||||
</ErrorDocument>
|
||||
<RoutingRules>
|
||||
<RoutingRule>
|
||||
<Condition>
|
||||
@@ -67,25 +64,28 @@ func TestBucketService_GetWebsite(t *testing.T) {
|
||||
}
|
||||
|
||||
want := &BucketGetWebsiteResult{
|
||||
XMLName: xml.Name{Local: "WebsiteConfiguration"},
|
||||
Index: "index.html",
|
||||
RedirectProtocol: "https",
|
||||
Error: "Error.html",
|
||||
Rules: []WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "img/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "demo.jpg",
|
||||
XMLName: xml.Name{Local: "WebsiteConfiguration"},
|
||||
Index: "index.html",
|
||||
RedirectProtocol: &RedirectRequestsProtocol{
|
||||
"https",
|
||||
},
|
||||
RoutingRules: &WebsiteRoutingRules{
|
||||
Rules: []WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "img/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "demo.jpg",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -100,24 +100,30 @@ func TestBucketService_PutWebsite(t *testing.T) {
|
||||
defer teardown()
|
||||
|
||||
opt := &BucketPutWebsiteOptions{
|
||||
Index: "index.html",
|
||||
RedirectProtocol: "https",
|
||||
Error: "Error.html",
|
||||
Rules: []WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "img/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "demo.jpg",
|
||||
Index: "index.html",
|
||||
RedirectProtocol: &RedirectRequestsProtocol{
|
||||
"https",
|
||||
},
|
||||
Error: &ErrorDocument{
|
||||
"Error.html",
|
||||
},
|
||||
RoutingRules: &WebsiteRoutingRules{
|
||||
[]WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "img/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "demo.jpg",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -307,19 +307,20 @@ func (s *CosTestSuite) TestPutGetDeleteLifeCycle() {
|
||||
|
||||
func (s *CosTestSuite) TestPutGetDeleteWebsite() {
|
||||
opt := &cos.BucketPutWebsiteOptions{
|
||||
Index: "index.html",
|
||||
Error: "index_backup.html",
|
||||
RedirectProtocol: "https",
|
||||
Rules: []cos.WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
Index: "index.html",
|
||||
Error: &cos.ErrorDocument{"index_backup.html"},
|
||||
RoutingRules: &cos.WebsiteRoutingRules{
|
||||
[]cos.WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -30,18 +30,20 @@ func main() {
|
||||
|
||||
opt := &cos.BucketPutWebsiteOptions{
|
||||
Index: "index.html",
|
||||
Error: "index_backup.html",
|
||||
RedirectProtocol: "https",
|
||||
Rules: []cos.WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
Error: &cos.ErrorDocument{"index_backup.html"},
|
||||
RedirectProtocol: &cos.RedirectRequestsProtocol{"https"},
|
||||
RoutingRules: &cos.WebsiteRoutingRules{
|
||||
[]cos.WebsiteRoutingRule{
|
||||
{
|
||||
ConditionErrorCode: "404",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKey: "404.html",
|
||||
},
|
||||
{
|
||||
ConditionPrefix: "docs/",
|
||||
RedirectProtocol: "https",
|
||||
RedirectReplaceKeyPrefix: "documents/",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user