Skip to content

Latest commit

 

History

History
61 lines (38 loc) · 1.14 KB

README.md

File metadata and controls

61 lines (38 loc) · 1.14 KB

go-http-proxy

A mockable http proxy

Go Report Card

Use Info

type Gresp struct{
    Status bool
    Message string
}
req, rErr := http.NewRequest("GET", "www.google.com/test", nil)

var resp Gresp
px := GoProxy{}
p := px.New()

callSuccess, httpStatusCode := p.Do(req, &resp)
// callSuccess indicates success of call
// httpStatusCode is status of the call
// resp contains the response---  make sure to pass a pointer

Use Info Mock

type Gresp struct{
    Status bool
    Message string
}
req, rErr := http.NewRequest("GET", "www.google.com/test", nil)

var w1 http.Response
	
w1.Body = ioutil.NopCloser(bytes.NewBufferString(`{"Status":true, "Message":"All good"}`))

var resp Gresp
px := MockGoProxy{}
px.MockDoSuccess1 = true
px.MockRespCode = 200
px.MockResp = &w1

p := px.New()

callSuccess, httpStatusCode := p.Do(req, &resp)
// callSuccess indicates success of call
// httpStatusCode is status of the call
// resp contains the response---  make sure to pass a pointer