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

  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "net/http"
  6. )
  7. type BucketPutRefererOptions struct {
  8. XMLName xml.Name `xml:"RefererConfiguration"`
  9. Status string `xml:"Status"`
  10. RefererType string `xml:"RefererType"`
  11. DomainList []string `xml:"DomainList>Domain"`
  12. EmptyReferConfiguration string `xml:"EmptyReferConfiguration,omitempty"`
  13. }
  14. type BucketGetRefererResult BucketPutRefererOptions
  15. func (s *BucketService) PutReferer(ctx context.Context, opt *BucketPutRefererOptions) (*Response, error) {
  16. sendOpt := &sendOptions{
  17. baseURL: s.client.BaseURL.BucketURL,
  18. uri: "/?referer",
  19. method: http.MethodPut,
  20. body: opt,
  21. }
  22. resp, err := s.client.doRetry(ctx, sendOpt)
  23. return resp, err
  24. }
  25. func (s *BucketService) GetReferer(ctx context.Context) (*BucketGetRefererResult, *Response, error) {
  26. var res BucketGetRefererResult
  27. sendOpt := &sendOptions{
  28. baseURL: s.client.BaseURL.BucketURL,
  29. uri: "/?referer",
  30. method: http.MethodGet,
  31. result: &res,
  32. }
  33. resp, err := s.client.doRetry(ctx, sendOpt)
  34. return &res, resp, err
  35. }