代码地址
https://github.com/poemp/ghttp/tree/main
使用方式
go get -u github.com/poemp/ghttp
Get请求
import (
"fmt"
"ghttp/ghttp"
)
func goGet() {
http := ghttp.NewHttp()
s := http.Headers(map[string]string{
"auth": "1234",
}).Get().Req("https://wwww.baidu.com", map[string]string{
"keyword":"golang",
})
fmt.Println(s)
}
Post请求
import (
"fmt"
"ghttp/ghttp"
)
func doPost(){
http := ghttp.NewHttp()
s :=http.Headers(map[string]string{
"auth":"ssss",
}).Post().Json().Req("https://127.0.0.1:8080", map[string]string{
"keyword":"golang",
})
fmt.Println(s)
}