1 Star 1 Fork 0

Ostaer/go-workwx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
client_options.go 1.04 KB
一键复制 编辑 原始数据 按行查看 历史
package workwx
import (
"net/http"
)
// DefaultQYAPIHost 默认企业微信 API Host
const DefaultQYAPIHost = "https://qyapi.weixin.qq.com"
type options struct {
QYAPIHost string
HTTP *http.Client
}
// CtorOption 客户端对象构造参数
type CtorOption interface {
applyTo(*options)
}
// impl Default for options
func defaultOptions() options {
return options{
QYAPIHost: DefaultQYAPIHost,
HTTP: &http.Client{},
}
}
//
//
//
type withQYAPIHost struct {
x string
}
// WithQYAPIHost 覆盖默认企业微信 API 域名
func WithQYAPIHost(host string) CtorOption {
return &withQYAPIHost{x: host}
}
var _ CtorOption = (*withQYAPIHost)(nil)
func (x *withQYAPIHost) applyTo(y *options) {
y.QYAPIHost = x.x
}
//
//
//
type withHTTPClient struct {
x *http.Client
}
// WithHTTPClient 使用给定的 http.Client 作为 HTTP 客户端
func WithHTTPClient(client *http.Client) CtorOption {
return &withHTTPClient{x: client}
}
var _ CtorOption = (*withHTTPClient)(nil)
func (x *withHTTPClient) applyTo(y *options) {
y.HTTP = x.x
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ostaer/go-workwx.git
git@gitee.com:ostaer/go-workwx.git
ostaer
go-workwx
go-workwx
b16c285aee72

搜索帮助