mirror of
https://github.com/woodchen-ink/certimate.git
synced 2025-07-19 01:41:55 +08:00
44 lines
928 B
Go
44 lines
928 B
Go
package cdnfly
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
type GetSiteResponse struct {
|
|
apiResponseBase
|
|
|
|
Data *struct {
|
|
Id int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Domain string `json:"domain"`
|
|
HttpsListen string `json:"https_listen"`
|
|
} `json:"data,omitempty"`
|
|
}
|
|
|
|
func (c *Client) GetSite(siteId string) (*GetSiteResponse, error) {
|
|
return c.GetSiteWithContext(context.Background(), siteId)
|
|
}
|
|
|
|
func (c *Client) GetSiteWithContext(ctx context.Context, siteId string) (*GetSiteResponse, error) {
|
|
if siteId == "" {
|
|
return nil, fmt.Errorf("sdkerr: unset siteId")
|
|
}
|
|
|
|
httpreq, err := c.newRequest(http.MethodGet, fmt.Sprintf("/sites/%s", url.PathEscape(siteId)))
|
|
if err != nil {
|
|
return nil, err
|
|
} else {
|
|
httpreq.SetContext(ctx)
|
|
}
|
|
|
|
result := &GetSiteResponse{}
|
|
if _, err := c.doRequestWithResult(httpreq, result); err != nil {
|
|
return result, err
|
|
}
|
|
|
|
return result, nil
|
|
}
|