本文整理汇总了Golang中launchpad/net/juju-core/environs.StorageReader.URL方法的典型用法代码示例。如果您正苦于以下问题:Golang StorageReader.URL方法的具体用法?Golang StorageReader.URL怎么用?Golang StorageReader.URL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/juju-core/environs.StorageReader
的用法示例。
在下文中一共展示了StorageReader.URL方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkFileHasContents
func checkFileHasContents(c *C, storage environs.StorageReader, name string, contents []byte, attempt trivial.AttemptStrategy) {
r, err := storage.Get(name)
c.Assert(err, IsNil)
c.Check(r, NotNil)
defer r.Close()
data, err := ioutil.ReadAll(r)
c.Check(err, IsNil)
c.Check(data, DeepEquals, contents)
url, err := storage.URL(name)
c.Assert(err, IsNil)
var resp *http.Response
for a := attempt.Start(); a.Next(); {
resp, err = http.Get(url)
c.Assert(err, IsNil)
if resp.StatusCode != 404 {
break
}
c.Logf("get retrying after earlier get succeeded. *sigh*.")
}
c.Assert(err, IsNil)
data, err = ioutil.ReadAll(resp.Body)
c.Assert(err, IsNil)
defer resp.Body.Close()
c.Assert(resp.StatusCode, Equals, 200, Commentf("error response: %s", data))
c.Check(data, DeepEquals, contents)
}
示例2: checkFileHasContents
func checkFileHasContents(c *C, storage environs.StorageReader, name string, contents []byte) {
r, err := storage.Get(name)
c.Assert(err, IsNil)
c.Check(r, NotNil)
defer r.Close()
data, err := ioutil.ReadAll(r)
c.Check(err, IsNil)
c.Check(data, DeepEquals, contents)
url, err := storage.URL(name)
c.Assert(err, IsNil)
resp, err := http.Get(url)
c.Assert(err, IsNil)
data, err = ioutil.ReadAll(resp.Body)
c.Assert(err, IsNil)
defer resp.Body.Close()
c.Assert(resp.StatusCode, Equals, http.StatusOK, Commentf("error response: %s", data))
c.Check(data, DeepEquals, contents)
}