学无先后,达者为师

网站首页 编程语言 正文

Golang 发送http请求工具

作者:鲁尼的小宝贝 更新时间: 2022-03-15 编程语言

代码地址

        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)
}

原文链接:https://blog.csdn.net/poem_2010/article/details/120804643

栏目分类
最近更新