本文整理匯總了Golang中github.com/dghubble/sling.Sling.New方法的典型用法代碼示例。如果您正苦於以下問題:Golang Sling.New方法的具體用法?Golang Sling.New怎麽用?Golang Sling.New使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/dghubble/sling.Sling
的用法示例。
在下文中一共展示了Sling.New方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: newStreamService
// newStreamService returns a new StreamService.
func newStreamService(client *http.Client, sling *sling.Sling) *StreamService {
sling.Set("User-Agent", userAgent)
return &StreamService{
client: client,
public: sling.New().Base(publicStream).Path("statuses/"),
user: sling.New().Base(userStream),
site: sling.New().Base(siteStream),
}
}
示例2:
bodyBytes, err := ioutil.ReadAll(resp.Body)
Expect(err).NotTo(HaveOccurred())
Expect(bodyBytes).To(ContainSubstring("<html>"))
})
It("should compute steady-state stats on /steady_state", func() {
requestData := models.SteadyStateRequest{
NumHosts: 1000,
NumApps: 10000,
MeanInstancesPerApp: 2,
}
var responseData models.SteadyStateResponse
var apiError models.APIError
resp, err := apiClient.New().Get("/steady_state").QueryStruct(requestData).Receive(&responseData, &apiError)
Expect(err).NotTo(HaveOccurred())
Expect(resp.StatusCode).To(Equal(200))
By("checking the CORS response")
Expect(resp.Header.Get("Access-Control-Allow-Origin")).To(Equal("*"))
By("checking the original request is included with the response")
Expect(responseData.Request).To(Equal(requestData))
By("checking the mean instances per host")
Expect(responseData.MeanInstancesPerHost).To(Equal(20.0))
By("checking the mean instances per host")
Expect(responseData.Apps).To(HaveLen(10000))
})
示例3: newDirectMessageService
// newDirectMessageService returns a new StatusService.
func newDirectMessageService(sling *sling.Sling) *DirectMessageService {
return &DirectMessageService{
baseSling: sling.New(),
sling: sling.Path("direct_messages/"),
}
}