Skip to content

Commit

Permalink
优化文档
Browse files Browse the repository at this point in the history
  • Loading branch information
guonaihong committed Nov 26, 2021
1 parent 91b54c7 commit 5fdb800
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Expand Up @@ -93,6 +93,7 @@ gout 是go写的http 客户端,为提高工作效率而开发
- [send raw http request](#send-raw-http-request)
- [export](#export)
- [generate curl command](#generate-curl-command)
- [generate curl command and send HTTP request](#generate-curl-command-and-send-http-request)
- [Incoming custom * http.Client](#Incoming-custom-*http.Client)
- [Using chunked data format](#Using-chunked-data-format)
- [NewWithOpt](#NewWithOpt)
Expand Down Expand Up @@ -1741,6 +1742,7 @@ Accept-Encoding: gzip
```
# export
## generate curl command
仅仅生成curl命令, 不会发送http请求
```go
package main
Expand All @@ -1767,6 +1769,35 @@ func main() {
fmt.Printf("%v\n", err)
}
```

## generate curl command and send HTTP request
生成curl命令, 同时执行http请求, 在```Curl()```命令之行跟上```GenAndSend()```接口
```go
package main
import (
"fmt"
"github.com/guonaihong/gout"
)
func main() {
// 1.formdata
err := gout.GET(":1234").
SetForm(gout.A{"text", "good", "mode", "A", "voice", gout.FormFile("./t8.go")}).
Export().Curl().GenAndSend().Do()
// output:
// curl -X GET -F "text=good" -F "mode=A" -F "voice=@./voice" "http://127.0.0.1:1234"
// 2.json body
err = gout.GET(":1234").
SetJSON(gout.H{"key1": "val1", "key2": "val2"}).
Export().Curl().GenAndSend().Do()
// output:
// curl -X GET -H "Content-Type:application/json" -d "{\"key1\":\"val1\",\"key2\":\"val2\"}" "http://127.0.0.1:1234"
fmt.Printf("%v\n", err)
}
```
# Incoming custom *http.Client
使用New接口即可使用自己的http.Client对象
Expand Down

0 comments on commit 5fdb800

Please sign in to comment.