Custom Domain

Last updated: 2020-03-20 11:05:33

PDF

Note

This document provides an overview of API for custom domain names and sample SDK code.

API Operation name pedagogical operation
PUT Bucket domain Set up a custom domain name Set Bucket's custom domain name information
GET Bucket domain Query custom domain name Query Bucket's custom domain name information

Set up a custom domain name

Function description

PUT Bucket domain is used to configure a custom domain name for Bucket.

Method prototype

func (s *BucketService) PutDomain(ctx context.Context, opt *BucketPutDomainOptions) (*Response, error)

Request Sample

opt := &cos.BucketPutDomainOptions{
    Status:            "ENABLED",
    Name:              "www.example.com",
    Type:              "REST",
    ForcedReplacement: "CNAME",
}   
resp, err := c.Bucket.PutDomain(context.Background(), opt)

Parameter description

type BucketPutDomainOptions struct {
    XMLName           xml.Name
    Status            string   
    Name              string   
    Type              string   
    ForcedReplacement string   
}
Parameter name Description Type
BucketPutDomainOptions Custom domain name configuration Struct
Status Domain name Activate / deactivate status, valid value ENABLED/DISABLED String
Name User's custom domain name. Valid values: letters, numbers, dots String
Type Bound real server type, valid value REST/WEBSITE String
ForcedReplacement Replace the existing configuration with a valid value of CNAME/TXT. Enter forcefully verifies the ownership of the domain name, and then deliver configures it. String

Returns the error code description

Some common special errors that may occur in this request are as follows:

Status Code Description
HTTP 409 Conflict The domain name record already exists and no mandatory overwrite is set in the request. Or the domain name record does not exist and a forced overwrite is set in the request
HTTP 451 Unavailable For Legal Reasons The domain name is a domain name within China, and there is no ICP filing.

Query custom domain name

Function description

GET Bucket domain is used to query Bucket's custom domain name information.

Method prototype

func (s *BucketService) GetDomain(ctx context.Context) (*BucketGetDomainResult, *Response, error)

Request Sample

v, resp, err := c.Bucket.GetDomain(context.Background())

Return result description

type BucketGetDomainResult BucketPutDomainOptions
Parameter name Description Type
BucketGetDomainResult Custom domain name configuration Struct
Status Domain name Activate / deactivate status, valid value ENABLED/DISABLED String
Name User's custom domain name. Valid values: letters, numbers, dots String
Type Bound real server type, valid value REST/WEBSITE String
ForcedReplacement Replace the existing configuration with a valid value of CNAME/TXT. Enter forcefully verifies the ownership of the domain name, and then deliver configures it. String