Documentation ¶
Index ¶
- Constants
- Variables
- func Config() *viper.Viper
- func NewHttpClient(fn RoundTripFunc) *http.Client
- func NewHttpClientSuite(suite []HttpClientSuite) *http.Client
- func NewRedis() *redis.Redis
- type HttpClientSuite
- type Request
- func (r *Request) BeforeHook(fn func(req *http.Request))
- func (r *Request) Form(values *url.Values) (*Response, error)
- func (r *Request) Get() (*Response, error)
- func (r *Request) JSON(data interface{}) (*Response, error)
- func (r *Request) Post(contentType string, body io.Reader) (*Response, error)
- func (r *Request) XML(body string) (*Response, error)
- type Response
- type RoundTripFunc
Constants ¶
View Source
const ( JsonContentType = "application/json; charset=utf-8" FormContentType = "application/x-www-form-urlencoded; charset=utf-8" XmlContentType = "application/xml; charset=utf-8" TextContentType = "text/plain; charset=utf-8" )
Variables ¶
View Source
var ( // 专供测试使用的RSA密钥对 RSAPublicKey = `` /* 450-byte string literal not displayed */ RSAPrivateKey = `` /* 1674-byte string literal not displayed */ )
View Source
var Conf *viper.Viper
Functions ¶
func NewHttpClient ¶
func NewHttpClient(fn RoundTripFunc) *http.Client
NewTestHttpClient returns *http.Client with Transport replaced to avoid making real calls
func NewHttpClientSuite ¶
func NewHttpClientSuite(suite []HttpClientSuite) *http.Client
NewHttpClientSuite quickly define HTTP Response for mock
Types ¶
type HttpClientSuite ¶
type HttpClientSuite struct { URI string MatchBody map[string]interface{} MatchQuery map[string]interface{} ResponseBody string StatusCode int Header http.Header Error error }
HttpClientSuite is test set for http client URI is need to match request uri MatchBody is need to match request body, The key of the Map is the JSON path, map["goods_defail.goods_id":"1"] MatchQuery is need to match request query params ResponseBody is http return body StatusCode is http status Header is response headers Error mock request exception
type Request ¶
func NewRequest ¶
func NewRequest(url string, handlers ...gee.HandlerFunc) *Request
func NewRequestWithPath ¶
func NewRequestWithPath(path, url string, handlers ...gee.HandlerFunc) *Request
func (*Request) BeforeHook ¶
type Response ¶
type Response struct {
*httptest.ResponseRecorder
}
func (*Response) GetBodyString ¶
Click to show internal directories.
Click to hide internal directories.