Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kirinlabs/HttpRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
kirinlabs committed Apr 16, 2024
2 parents 86f8bd9 + 432628e commit 1c9ff23
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
HttpRequest
=======
A simple `HTTP Request` package for golang. `GET` `POST` `DELETE` `PUT` `Upload`
A simple `HTTP Request` package for golang. `GET` `POST` `DELETE` `PUT`



Expand All @@ -12,8 +12,19 @@ go get github.com/kirinlabs/HttpRequest

#### Create request object use http.DefaultTransport
```go
resp, err := HttpRequest.Get("http://127.0.0.1:8000")
resp, err := HttpRequest.SetTimeout(5).Get("http://127.0.0.1:8000")
resp, err := HttpRequest.Debug(true).SetHeaders(map[string]string{}).Get("http://127.0.0.1:8000")

OR

req := HttpRequest.NewRequest()
req := HttpRequest.NewRequest().Debug(true).SetTimeout(5)
resp, err := req.Get("http://127.0.0.1:8000")
resp, err := req.Get("http://127.0.0.1:8000",nil)
resp, err := req.Get("http://127.0.0.1:8000?id=10&title=HttpRequest")
resp, err := req.Get("http://127.0.0.1:8000?id=10&title=HttpRequest","address=beijing")

```

#### Set headers
Expand All @@ -35,9 +46,11 @@ req.SetCookies(map[string]string{
"token":"",
})

req.SetCookies(map[string]string{
OR

HttpRequest.SetCookies(map[string]string{
"age":"19",
})
}).Post()
```

#### Set basic auth
Expand Down Expand Up @@ -111,6 +124,8 @@ resp, err := req.Get("http://127.0.0.1:8000",nil)
resp, err := req.Get("http://127.0.0.1:8000?id=10&title=HttpRequest")
resp, err := req.Get("http://127.0.0.1:8000?id=10&title=HttpRequest","address=beijing")

OR

resp, err := HttpRequest.Get("http://127.0.0.1:8000")
resp, err := HttpRequest.Debug(true).SetHeaders(map[string]string{}).Get("http://127.0.0.1:8000")
```
Expand Down

0 comments on commit 1c9ff23

Please sign in to comment.