Simple HTTP and REST client library for Go。简单理解 java里的HttpClient,用于发送http 或rest协议的请求。
github:GitHub - go-resty/resty: Simple HTTP and REST client library for Go
api doc:resty package - github.com/go-resty/resty - pkg.go.dev
应用实例:
import "github.com/go-resty/resty/v2"
func main(){
//创建resty client实例
client := resty.New()
//1 get url访问
resp, err := client.R().EnableTrace().Get("https://httpbin.org/get")
//2 get 设置参数map 访问
resp, err := client.R().
SetQueryParams(map[string]string{
"page_no": "1",
"limit": "20",
}).
SetHeader("Accept"