当前位置: 首页>>代码示例>>Golang>>正文


Golang Sling.Request方法代码示例

本文整理汇总了Golang中github.com/dghubble/sling.Sling.Request方法的典型用法代码示例。如果您正苦于以下问题:Golang Sling.Request方法的具体用法?Golang Sling.Request怎么用?Golang Sling.Request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/dghubble/sling.Sling的用法示例。


在下文中一共展示了Sling.Request方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: DoRequest

func DoRequest(r *sling.Sling) *http.Response {
	req, err := r.Request()
	Expect(err).To(BeNil())
	response, err := http.DefaultClient.Do(req)

	Expect(err).To(BeNil())
	return response
}
开发者ID:SpectoLabs,项目名称:hoverfly,代码行数:8,代码来源:ft_suite_test.go

示例2: DoRequestThroughProxy

func DoRequestThroughProxy(r *sling.Sling) *http.Response {
	req, err := r.Request()
	Expect(err).To(BeNil())

	proxy, err := url.Parse(hoverflyProxyUrl)
	proxyHttpClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxy)}}
	response, err := proxyHttpClient.Do(req)

	Expect(err).To(BeNil())

	return response
}
开发者ID:SpectoLabs,项目名称:hoverfly,代码行数:12,代码来源:ft_suite_test.go

示例3: DoRequestThroughProxy

func DoRequestThroughProxy(r *sling.Sling) *http.Response {
	req, err := r.Request()
	Expect(err).To(BeNil())

	proxy, err := url.Parse(hoverflyProxyUrl)
	proxyHttpClient := &http.Client{Transport: &http.Transport{Proxy: http.ProxyURL(proxy)}, CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
	response, err := proxyHttpClient.Do(req)

	Expect(err).To(BeNil())

	return response
}
开发者ID:SpectoLabs,项目名称:hoverfly,代码行数:12,代码来源:ft_suite_test.go

示例4: request

func request(_sling *sling.Sling, acceptHeader string, authInfo ...usrInfo) (int, []byte, error) {
	_sling = _sling.Set("Accept", acceptHeader)
	req, err := _sling.Request()
	if err != nil {
		return 400, nil, err
	}
	if len(authInfo) > 0 {
		req.SetBasicAuth(authInfo[0].Name, authInfo[0].Passwd)
	}
	w := httptest.NewRecorder()
	beego.BeeApp.Handlers.ServeHTTP(w, req)
	body, err := ioutil.ReadAll(w.Body)
	return w.Code, body, err
}
开发者ID:vmware,项目名称:harbor,代码行数:14,代码来源:harborapi_test.go

示例5: doRequest

func (h *Hoverfly) doRequest(request *sling.Sling) (*http.Response, error) {
	httpRequest, err := request.Request()
	if err != nil {
		log.Debug(err.Error())
		return nil, errors.New("Could not communicate with Hoverfly")
	}

	response, err := h.httpClient.Do(httpRequest)
	if err != nil {
		log.Debug(err.Error())
		return nil, errors.New("Could not communicate with Hoverfly")
	}

	if response.StatusCode == 401 {
		return nil, errors.New("Hoverfly requires authentication")
	}

	return response, nil
}
开发者ID:SpectoLabs,项目名称:hoverfly,代码行数:19,代码来源:hoverfly.go

示例6: performAPIRequest

func (h *Hoverfly) performAPIRequest(slingRequest *sling.Sling) (*http.Response, error) {
	slingRequest, err := h.addAuthIfNeeded(slingRequest)
	if err != nil {
		log.Warn(err.Error())
		return nil, errors.New("Could not authenticate  with Hoverfly")
	}

	request, err := slingRequest.Request()

	if err != nil {
		log.Warn(err.Error())
		return nil, errors.New("Could not communicate with Hoverfly")
	}

	response, err := h.httpClient.Do(request)
	if err != nil {
		log.Warn(err.Error())
		return nil, errors.New("Could not communicate with Hoverfly")
	}
	return response, nil

}
开发者ID:SpectoLabs,项目名称:hoverfly,代码行数:22,代码来源:template.go


注:本文中的github.com/dghubble/sling.Sling.Request方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。