Documentation ¶
Index ¶
- Constants
- func DownloadToDirectory(ctx context.Context, saveDirectory, targetUrl string, ...) error
- func GetBytes(ctx context.Context, targetUrl string, options ...*Options[any, []byte]) ([]byte, error)
- func GetJson[Response any](ctx context.Context, targetUrl string, options ...*Options[any, Response]) (Response, error)
- func GetString(ctx context.Context, targetUrl string, options ...*Options[any, []byte]) (string, error)
- func GetYaml[Response any](ctx context.Context, targetUrl string, options ...*Options[any, Response]) (Response, error)
- func MyUserAgent() string
- func PostJson[Request any, Response any](ctx context.Context, targetUrl string, request Request, ...) (Response, error)
- func SendRequest[Request any, Response any](ctx context.Context, options *Options[Request, Response]) (Response, error)
- type Detector
- type GitHubRepoCacheMeta
- type GitHubRepoDownloader
- func (x *GitHubRepoDownloader) BuildCacheMetaFilePath(downloadDirectory string) string
- func (x *GitHubRepoDownloader) Download(ctx context.Context, options *GitHubRepoDownloaderOptions) error
- func (x *GitHubRepoDownloader) ReadCacheMeta(downloadDirectory string) (*GitHubRepoCacheMeta, error)
- func (x *GitHubRepoDownloader) Save(downloadDirectory string, meta *GitHubRepoCacheMeta) error
- type GitHubRepoDownloaderOptions
- type Options
- func (x *Options[Request, Response]) AppendRequestSetting(requestSetting RequestSetting) *Options[Request, Response]
- func (x *Options[Request, Response]) SendMessage(message *schema.Diagnostics) *Options[Request, Response]
- func (x *Options[Request, Response]) WithBody(body []byte) *Options[Request, Response]
- func (x *Options[Request, Response]) WithJsonResponseHandler() *Options[Request, Response]
- func (x *Options[Request, Response]) WithMaxTryTimes(maxTryTimes int) *Options[Request, Response]
- func (x *Options[Request, Response]) WithMessageChannel(messageChannel chan *schema.Diagnostics) *Options[Request, Response]
- func (x *Options[Request, Response]) WithMethod(method string) *Options[Request, Response]
- func (x *Options[Request, Response]) WithRequestSettingSlice(requestSettingSlice []RequestSetting) *Options[Request, Response]
- func (x *Options[Request, Response]) WithResponseHandler(responseHandler ResponseHandler[Response]) *Options[Request, Response]
- func (x *Options[Request, Response]) WithTargetURL(targetURL string) *Options[Request, Response]
- func (x *Options[Request, Response]) WithYamlResponseHandler() *Options[Request, Response]
- type RequestSetting
- type ResponseHandler
- func BytesResponseHandler(readResponseOnStatusCodeIn ...int) ResponseHandler[[]byte]
- func JsonResponseHandler[Response any](readResponseOnStatusCodeIn ...int) ResponseHandler[Response]
- func StringResponseHandler(readResponseOnStatusCodeIn ...int) ResponseHandler[string]
- func YamlResponseHandler[Response any](readResponseOnStatusCodeIn ...int) ResponseHandler[Response]
Constants ¶
View Source
const DefaultMaxTryTimes = 3
View Source
const DefaultMethod = http.MethodGet
View Source
const DefaultUserAgent = "selefra-cli"
Variables ¶
This section is empty.
Functions ¶
func DownloadToDirectory ¶
func DownloadToDirectory(ctx context.Context, saveDirectory, targetUrl string, progressListener getter.ProgressTracker, options ...getter.ClientOption) error
func MyUserAgent ¶ added in v0.0.11
func MyUserAgent() string
Types ¶
type GitHubRepoCacheMeta ¶
type GitHubRepoCacheMeta struct { // The last download time of the repo DownloadTime time.Time `json:"download-time"` }
GitHubRepoCacheMeta Cache information from the github repository
type GitHubRepoDownloader ¶
type GitHubRepoDownloader struct { }
func NewGitHubRepoDownloader ¶
func NewGitHubRepoDownloader() *GitHubRepoDownloader
func (*GitHubRepoDownloader) BuildCacheMetaFilePath ¶
func (x *GitHubRepoDownloader) BuildCacheMetaFilePath(downloadDirectory string) string
BuildCacheMetaFilePath The root path of the downloaded repository is followed by a cache metadata-related file
func (*GitHubRepoDownloader) Download ¶
func (x *GitHubRepoDownloader) Download(ctx context.Context, options *GitHubRepoDownloaderOptions) error
func (*GitHubRepoDownloader) ReadCacheMeta ¶
func (x *GitHubRepoDownloader) ReadCacheMeta(downloadDirectory string) (*GitHubRepoCacheMeta, error)
ReadCacheMeta the github repository cache
func (*GitHubRepoDownloader) Save ¶
func (x *GitHubRepoDownloader) Save(downloadDirectory string, meta *GitHubRepoCacheMeta) error
Save the github repository cache information
type GitHubRepoDownloaderOptions ¶
type GitHubRepoDownloaderOptions struct { // Who owns the warehouse, org name or username Owner string // Name of warehouse Repo string // Which directory to download it to DownloadDirectory string // Whether to use a cache, using a cache can avoid repeat download in a short time // Open is suitable for large warehouse, when the warehouse itself is not large, you can download it directly CacheTime *time.Duration // It may take a while, but some messages will be sent to you if needed MessageChannel chan *schema.Diagnostics ProgressListener getter.ProgressTracker }
GitHubRepoDownloaderOptions download github
type Options ¶
type Options[Request any, Response any] struct { MaxTryTimes int TargetURL string Method string Body []byte RequestSettingSlice []RequestSetting ResponseHandler ResponseHandler[Response] MessageChannel chan *schema.Diagnostics }
func NewOptions ¶
func NewOptions[Request any, Response any](targetUrl string, responseHandler ResponseHandler[Response]) *Options[Request, Response]
func (*Options[Request, Response]) AppendRequestSetting ¶
func (x *Options[Request, Response]) AppendRequestSetting(requestSetting RequestSetting) *Options[Request, Response]
func (*Options[Request, Response]) SendMessage ¶
func (x *Options[Request, Response]) SendMessage(message *schema.Diagnostics) *Options[Request, Response]
func (*Options[Request, Response]) WithJsonResponseHandler ¶
func (*Options[Request, Response]) WithMaxTryTimes ¶
func (*Options[Request, Response]) WithMessageChannel ¶
func (x *Options[Request, Response]) WithMessageChannel(messageChannel chan *schema.Diagnostics) *Options[Request, Response]
func (*Options[Request, Response]) WithMethod ¶
func (*Options[Request, Response]) WithRequestSettingSlice ¶
func (x *Options[Request, Response]) WithRequestSettingSlice(requestSettingSlice []RequestSetting) *Options[Request, Response]
func (*Options[Request, Response]) WithResponseHandler ¶
func (x *Options[Request, Response]) WithResponseHandler(responseHandler ResponseHandler[Response]) *Options[Request, Response]
func (*Options[Request, Response]) WithTargetURL ¶
func (*Options[Request, Response]) WithYamlResponseHandler ¶
type RequestSetting ¶
func DefaultUserAgentRequestSetting ¶
func DefaultUserAgentRequestSetting() RequestSetting
type ResponseHandler ¶
ResponseHandler A component used to process http responses
func BytesResponseHandler ¶
func BytesResponseHandler(readResponseOnStatusCodeIn ...int) ResponseHandler[[]byte]
BytesResponseHandler The default response handler, automatically reads the response body when the response code is a given value
func JsonResponseHandler ¶
func JsonResponseHandler[Response any](readResponseOnStatusCodeIn ...int) ResponseHandler[Response]
func StringResponseHandler ¶
func StringResponseHandler(readResponseOnStatusCodeIn ...int) ResponseHandler[string]
func YamlResponseHandler ¶
func YamlResponseHandler[Response any](readResponseOnStatusCodeIn ...int) ResponseHandler[Response]
Click to show internal directories.
Click to hide internal directories.