使用odin自带vendor的curl简单包装post、get请求
也可以看看easy_test.odin文件
- 用git克隆当前仓库
- 在自己项目中导入当前仓库,
import "curleasy" - (可选)设置log的过程(函数)(
core:log)用来打印一些日志, 当前仓库使用了log.warnf, 在easyGet和easyPost时指定verbose参数时使用了log.infof - 开始使用, 见下面例子
// 设置日志
logger := log.create_console_logger()
defer log.destroy_console_logger(logger)
context.logger = logger
easy := Easy_get(
"http://www.baidu.com",
[]string {
"user-agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36 Edg/145.0.0.0",
"content-type: text/plain",
},
verbose = false,
)
defer Easy_free(easy)