You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.1 KiB
40 lines
1.1 KiB
package cos
|
|
|
|
import (
|
|
"context"
|
|
"encoding/xml"
|
|
"net/http"
|
|
)
|
|
|
|
type BucketPutRefererOptions struct {
|
|
XMLName xml.Name `xml:"RefererConfiguration"`
|
|
Status string `xml:"Status"`
|
|
RefererType string `xml:"RefererType"`
|
|
DomainList []string `xml:"DomainList>Domain"`
|
|
EmptyReferConfiguration string `xml:"EmptyReferConfiguration,omitempty"`
|
|
}
|
|
|
|
type BucketGetRefererResult BucketPutRefererOptions
|
|
|
|
func (s *BucketService) PutReferer(ctx context.Context, opt *BucketPutRefererOptions) (*Response, error) {
|
|
sendOpt := &sendOptions{
|
|
baseURL: s.client.BaseURL.BucketURL,
|
|
uri: "/?referer",
|
|
method: http.MethodPut,
|
|
body: opt,
|
|
}
|
|
resp, err := s.client.doRetry(ctx, sendOpt)
|
|
return resp, err
|
|
}
|
|
|
|
func (s *BucketService) GetReferer(ctx context.Context) (*BucketGetRefererResult, *Response, error) {
|
|
var res BucketGetRefererResult
|
|
sendOpt := &sendOptions{
|
|
baseURL: s.client.BaseURL.BucketURL,
|
|
uri: "/?referer",
|
|
method: http.MethodGet,
|
|
result: &res,
|
|
}
|
|
resp, err := s.client.doRetry(ctx, sendOpt)
|
|
return &res, resp, err
|
|
}
|