Skip to content

Commit

Permalink
Merge pull request #15 from wklken/develop
Browse files Browse the repository at this point in the history
v1.0.0-beta
  • Loading branch information
wklken authored Jan 13, 2022
2 parents 33c93e0 + 13ca153 commit a70e40a
Show file tree
Hide file tree
Showing 8 changed files with 382 additions and 36 deletions.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
GoRequest
=========


GoRequest -- Simplified HTTP client ( inspired by famous SuperAgent lib in Node.js )

![GopherGoRequest](https://raw.githubusercontent.com/parnurzeal/gorequest/gh-pages/images/Gopher_GoRequest_400x300.jpg)
Expand All @@ -25,7 +26,7 @@ Sending request has never been as fun nor easier than this. It comes with lots o
## Installation

```bash
$ go get github.com/parnurzeal/gorequest
$ go get github.com/wklken/gorequest
```

## Documentation
Expand Down Expand Up @@ -116,7 +117,7 @@ Compared to our GoRequest version, JSON is for sure a default. So, it turns out
```go
request := gorequest.New()
resp, body, errs := request.Post("http://example.com").
Set("Notes","gorequst is coming!").
Set("Notes","gorequest is coming!").
Send(`{"name":"backy", "species":"dog"}`).
End()
```
Expand Down Expand Up @@ -176,6 +177,31 @@ gorequest.New().Post("http://example.com/").

Check the docs for `SendFile` to get more information about the types of arguments.

## Headers

When setting one header to the request, the `Set` method can be used:

```go
gorequest.New().
Post("/gamelist").
Set("Accept", "application/json").
End()
```

This will clear all headers currently attached to a request and add the specified header.

If there are multiple headers that must be appended to the request before sending, use `AppendHeader`. These can be chained together to add additional headers to the request:

```go
gorequest.New().
Post("/gamelist").
AppendHeader("Accept", "application/json").
AppendHeader("Accept", "text/plain").
End()
```

See the docs for the `Set` and `AppendHeader` methods for information about parameter and return types.

## Proxy

In the case when you are behind proxy, GoRequest can handle it easily with Proxy func:
Expand Down
4 changes: 4 additions & 0 deletions constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ var Types = map[string]string{
TypeText: "text/plain",
TypeMultipart: "multipart/form-data",
}

const (
MIMEJSON = "application/json"
)
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.16
require (
github.com/elazarl/goproxy v0.0.0-20211114080932-d06c3be7c11b
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/spf13/cast v1.4.1
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f
moul.io/http2curl v1.0.0
)
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/elazarl/goproxy v0.0.0-20211114080932-d06c3be7c11b h1:1XqENn2YoYZd6w3Awx+7oa+aR87DFIZJFLF2n1IojA0=
github.com/elazarl/goproxy v0.0.0-20211114080932-d06c3be7c11b/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM=
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 h1:dWB6v3RcOy03t/bUadywsbyrQwCqZeNIEX6M1OtSZOM=
Expand All @@ -6,11 +8,17 @@ github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGa
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
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/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=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg=
github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM=
github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=
Expand Down
Loading

0 comments on commit a70e40a

Please sign in to comment.