Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.1 #28

Merged
merged 20 commits into from
Feb 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
0a7443c
feat(headers): set user-agent by s.UserAgent("")
wklken Jan 23, 2022
b6763a2
feat(feature/stats): add Stats for SuperAgent
wklken Jan 24, 2022
c963406
feat(ft/disablecompression): add DisableCompression()
wklken Jan 25, 2022
1372257
feat(mock): add Mock() support HTTP mocking
wklken Jan 25, 2022
f2eb2e0
fix(transport): update safeModifyTransport() copy transport to suppor…
wklken Jan 25, 2022
f25a6c1
fix(force_type): forceType not working while it's only be changed in …
wklken Jan 25, 2022
e87ba00
feat(sendfile): enable custom Content-Type for SendFile
wklken Feb 10, 2022
3784d51
feat(timeout): support http client timeout details
wklken Feb 11, 2022
c5f3b34
test(useragent): add unittest for UserAgent()
wklken Feb 19, 2022
715896f
Create go.yml
wklken Feb 19, 2022
298ac5f
Merge pull request #20 from wklken/ft_user_agent
wklken Feb 19, 2022
0b8d3f4
Merge pull request #22 from wklken/ft_disable_compression
wklken Feb 19, 2022
c6b2a6f
Merge pull request #24 from wklken/fix_go_1.16_transport
wklken Feb 19, 2022
b74826a
Merge pull request #25 from wklken/fix_force_type
wklken Feb 19, 2022
87db5f5
Merge pull request #26 from wklken/208_enable_custom_sendfile_content…
wklken Feb 19, 2022
2305408
Merge pull request #27 from wklken/ft_timeout_details
wklken Feb 19, 2022
a5295bf
Merge pull request #23 from wklken/ft_mock
wklken Feb 19, 2022
fe76e13
Merge branch 'develop' into ft_add_stats
wklken Feb 19, 2022
fc374f0
Merge pull request #21 from wklken/ft_add_stats
wklken Feb 19, 2022
3c00f6e
chore(version): 1.0.1
wklken Feb 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Go

on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17

- name: Test
run: go test -v ./...
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
GoRequest Changelog
=========

## GoRequest v1.0.1 (2022-02-19)

### BUGFIXES

- forceType not working while it's only be changed in getResponseBytes https://github.com/wklken/gorequest/pull/25

### ENHANCEMENTS

- add: UserAgent(), set user-agent by s.UserAgent("") https://github.com/wklken/gorequest/pull/20
- add: Stats, collecte statistics for SuperAgent request https://github.com/wklken/gorequest/pull/21
- add: DisableCompression() https://github.com/wklken/gorequest/pull/22
- add: Mock() support HTTP mocking https://github.com/wklken/gorequest/pull/23
- add: Timeouts() support http client timeout details https://github.com/wklken/gorequest/pull/27
- enable custom Content-Type for SendFile https://github.com/wklken/gorequest/pull/26

### OTHERS

- upgrade safeModifyTransport() copy transport to support go 1.16 https://github.com/wklken/gorequest/pull/24

## GoRequest v1.0.0 (2022-01-19)

### BUGFIXES
Expand Down
37 changes: 33 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ $ go get github.com/wklken/gorequest
```

## Documentation
See [Go Doc](http://godoc.org/github.com/wklken/gorequest) or [Go Walker](http://gowalker.org/github.com/wklken/gorequest) for usage and details.

See [Go Doc](http://godoc.org/github.com/wklken/gorequest) for usage and details.

## Status

[![Drone Build Status](https://drone.io/github.com/jmcvetta/restclient/status.png)](https://drone.io/github.com/parnurzeal/gorequest/latest)
[![Travis Build Status](https://travis-ci.org/parnurzeal/gorequest.svg?branch=master)](https://travis-ci.org/parnurzeal/gorequest)
[![Drone Build Status](https://drone.io/github.com/jmcvetta/restclient/status.png)](https://drone.io/github.com/wklken/gorequest/latest)
[![Travis Build Status](https://travis-ci.org/wklken/gorequest.svg?branch=master)](https://travis-ci.org/wklken/gorequest)

## Why should you use GoRequest?

Expand Down Expand Up @@ -311,6 +312,33 @@ baseRequest.Timeout(10 * time.Millisecond).
resp, body, errs := baseRequest.Clone().Get("http://exmaple.com/").End()
```

## Mock

You can mock the response of gorequest via [gock](https://github.com/h2non/gock)

```go
func TestMock(t *testing.T) {
defer gock.Off()

gock.New("http://foo.com").
Get("/bar").
Reply(200).
JSON(map[string]string{"foo": "bar"})

resp, body, errs := New().Mock().Get("http://foo.com/bar").SetDebug(true).End()
if len(errs) != 0 {
t.Fatalf("Expected no error, got error")
}
if resp.StatusCode != 200 {
t.Fatalf("Expected status code 200, got %d", resp.StatusCode)
}

if strings.Trim(body, " \n") != `{"foo":"bar"}` {
t.Fatalf("Expected body `{\"foo\":\"bar\"}`, got `%s`", body)
}
}
```

## Debug

For debugging, GoRequest leverages `httputil` to dump details of every request/response. (Thanks to @dafang)
Expand Down Expand Up @@ -357,9 +385,10 @@ Thanks to all contributors thus far:
| https://github.com/xild |
| https://github.com/yangmls |
| https://github.com/6david9 |
| https://github.com/wklken |


Also, co-maintainer is needed here. If anyone is interested, please email me (parnurzeal at gmail.com)
Also, co-maintainer is needed here. If anyone is interested, please email me (wklken at gmail.com)

## Credits

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ require (
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/spf13/cast v1.4.1
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f
gopkg.in/h2non/gock.v1 v1.1.2
moul.io/http2curl v1.0.0
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy0
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2/go.mod h1:gNh8nYJoAm43RfaxurUnxr+N1PwuFV3ZMl/efxlIlY8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw=
github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 h1:W6apQkHrMkS0Muv8G/TipAy/FJl/rCYT0+EuS8+Z0z4=
github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32/go.mod h1:9wM+0iRr9ahx58uYLpLIr5fm8diHn0JbqRycJi6w0Ms=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
Expand All @@ -31,5 +35,7 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY=
gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0=
moul.io/http2curl v1.0.0 h1:6XwpyZOYsgZJrU8exnG87ncVkU1FVCcTRpwzOkTDUi8=
moul.io/http2curl v1.0.0/go.mod h1:f6cULg+e4Md/oW1cYmwW4IWQOVl2lGbmCNGOHvzX2kE=
Loading