Documentation
¶
Index ¶
- Variables
- func Join(in any) error
- func LoadEdges(in reflect.Type) [][2]int
- func NewJoin[T any](in T) (*T, error)
- func NextTimeDuration(hour, min, sec int) time.Duration
- func ParseEdges(elem reflect.Type) (edges [][2]int)
- func Shell(s string, dir string, keep bool) ([]string, error)
- func SplitLines(s string) (r []string)
- func StrToAny(conds []string) []any
- type Client
- type DateHook
- type Downloader
- type JoinError
- type Node
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidName = errors.New("webhook/utils: invalid join tag value") ErrNotPointer = errors.New("webhook/utils: value must be a pointer to struct") )
View Source
var ErrInvalidURL = errors.New("webhook/file: invalid URL")
Functions ¶
func NextTimeDuration ¶ added in v0.15.0
func ParseEdges ¶ added in v0.15.0
func SplitLines ¶ added in v0.14.0
Types ¶
type Client ¶ added in v0.19.0
type Client interface {
// 在选择客户端时,会根据主机名进行匹配
// 返回值包含 example.com 时会匹配所有 *.example.com 的请求
Hosts() []string
// 自定义请求方法,可以添加请求头、鉴权参数、Cookies 之类
Get(url string) (*http.Response, error)
}
客户端接口
type DateHook ¶ added in v0.15.0
type DateHook struct {
// 输出日志文件的路径
// 会利用日志事件的时间进行格式化处理
// 参考值 "logs/2006-01-02.log"
Format string
// 日志等级
// 为空默认 logrus.AllLevels
LogLevels []logrus.Level
// contains filtered or unexported fields
}
以天为单位分割日志的钩子 为 logrus.Logger 添加此钩子仅能实现日志刷新,如果要写入还需将其设为 logrus.Logger.Out
type Downloader ¶ added in v0.19.0
type Downloader struct {
// 保存文件的根目录
Root string
// contains filtered or unexported fields
}
下载器
对于一个地址为 https://www.example.com/public/data.txt 文件 会保存在 $Root/www.example.com/public/data.txt
func NewDownloader ¶ added in v0.19.0
func NewDownloader(root string, client ...Client) *Downloader
func (*Downloader) Download ¶ added in v0.19.0
func (d *Downloader) Download(url string) (http.File, error)
下载文件
func (*Downloader) Open ¶ added in v0.19.0
func (d *Downloader) Open(name string) (http.File, error)
打开文件
会先尝试在本地访问,如果不存在再从网络下
func (*Downloader) Register ¶ added in v0.19.0
func (d *Downloader) Register(client ...Client)
注册客户端
Click to show internal directories.
Click to hide internal directories.