Ai
1 Star 1 Fork 1

大滴锦/我常用的的go_func

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Response.go 624 Bytes
一键复制 编辑 原始数据 按行查看 历史
大滴锦 提交于 2023-06-15 09:04 +08:00 . 首次保存
package GoCurlTool
import (
"io/ioutil"
"net/http"
)
type Response struct {
Raw *http.Response
Headers map[string]string
Body string
}
func NewResponse() *Response {
return &Response{}
}
func (this *Response) IsOk() bool {
return this.Raw.StatusCode == 200
}
func (this *Response) parseHeaders() error {
headers := map[string]string{}
for k, v := range this.Raw.Header {
headers[k] = v[0]
}
this.Headers = headers
return nil
}
func (this *Response) parseBody() error {
if body, err := ioutil.ReadAll(this.Raw.Body); err != nil {
panic(err)
} else {
this.Body = string(body)
}
return nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/dadjin/my-commonly-used-go-func.git
git@gitee.com:dadjin/my-commonly-used-go-func.git
dadjin
my-commonly-used-go-func
我常用的的go_func
v0.1.4

搜索帮助