本文整理汇总了Golang中github.com/concourse/go-concourse/concourse.Client.HTTPClient方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.HTTPClient方法的具体用法?Golang Client.HTTPClient怎么用?Golang Client.HTTPClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/go-concourse/concourse.Client
的用法示例。
在下文中一共展示了Client.HTTPClient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Download
func Download(client concourse.Client, output Output) {
path := output.Path
pipe := output.Pipe
response, err := client.HTTPClient().Get(pipe.ReadURL)
if err != nil {
fmt.Fprintln(os.Stderr, "download request failed:", err)
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
fmt.Fprintln(os.Stderr, badResponseError("downloading bits", response))
panic("unexpected-response-code")
}
err = os.MkdirAll(path, 0755)
if err != nil {
panic(err)
}
err = tarStreamTo(path, response.Body)
if err != nil {
panic(err)
}
}
示例2: Upload
func Upload(client concourse.Client, input Input, excludeIgnored bool) {
path := input.Path
pipe := input.Pipe
var files []string
var err error
if excludeIgnored {
files, err = getGitFiles(path)
if err != nil {
fmt.Fprintln(os.Stderr, "could not determine ignored files:", err)
return
}
} else {
files = []string{"."}
}
archive, err := tarStreamFrom(path, files)
if err != nil {
fmt.Fprintln(os.Stderr, "could create tar stream:", err)
return
}
defer archive.Close()
upload, err := http.NewRequest("PUT", pipe.WriteURL, archive)
if err != nil {
panic(err)
}
response, err := client.HTTPClient().Do(upload)
if err != nil {
fmt.Fprintln(os.Stderr, "upload request failed:", err)
return
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
fmt.Fprintln(os.Stderr, badResponseError("uploading bits", response))
}
}