https://github.com/golangtoolkits/go-http-proxy
A mockable http proxy
https://github.com/golangtoolkits/go-http-proxy
go golang http http-proxy proxy
Last synced: about 1 year ago
JSON representation
A mockable http proxy
- Host: GitHub
- URL: https://github.com/golangtoolkits/go-http-proxy
- Owner: GolangToolKits
- License: mit
- Created: 2023-02-04T22:20:59.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-05T22:03:26.000Z (almost 3 years ago)
- Last Synced: 2025-01-12T21:07:18.169Z (about 1 year ago)
- Topics: go, golang, http, http-proxy, proxy
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-http-proxy
A mockable http proxy
[](https://goreportcard.com/report/github.com/GolangToolKits/go-http-proxy)
### Use Info
```go
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
```go
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
```