go-wxhelper/config/wechat.go
李寻欢 8f15b58825
All checks were successful
BuildImage / build-image (push) Successful in 1m9s
🎨 逻辑修改,把依赖从写死改为配置
2023-10-26 10:07:08 +08:00

34 lines
766 B
Go

package config
import "strings"
// wxHelper
// @description: 微信助手
type wechat struct {
Host string `json:"host" yaml:"host"` // 接口地址
AutoSetCallback bool `json:"autoSetCallback" yaml:"autoSetCallback"` // 是否自动设置回调地址
Callback string `json:"callback" yaml:"callback"` // 回调地址
}
// Check
// @description: 检查配置是否可用
// @receiver w
// @return bool
func (w wechat) Check() bool {
if w.Host == "" {
return false
}
if w.AutoSetCallback && w.Callback == "" {
return false
}
return true
}
func (w wechat) GetURL(uri string) string {
host := w.Host
if !strings.HasPrefix(w.Host, "http://") {
host = "http://" + w.Host
}
return host + uri
}