當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Sling.New方法代碼示例

本文整理匯總了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),
	}
}
開發者ID:dougnukem,項目名稱:go-twitter,代碼行數:10,代碼來源:streams.go

示例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))
	})
開發者ID:rosenhouse,項目名稱:cnsim,代碼行數:30,代碼來源:acceptance_test.go

示例3: newDirectMessageService

// newDirectMessageService returns a new StatusService.
func newDirectMessageService(sling *sling.Sling) *DirectMessageService {
	return &DirectMessageService{
		baseSling: sling.New(),
		sling:     sling.Path("direct_messages/"),
	}
}
開發者ID:dougnukem,項目名稱:go-twitter,代碼行數:7,代碼來源:direct_messages.go


注:本文中的github.com/dghubble/sling.Sling.New方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。