Feat: onedrive client upload / callback

This commit is contained in:
HFO4
2020-01-20 14:34:21 +08:00
parent 807aa5ac18
commit dd5f6e3d25
10 changed files with 359 additions and 35 deletions

View File

@@ -1,14 +1,18 @@
package onedrive
import "time"
// Option 发送请求的额外设置
type Option interface {
apply(*options)
}
type options struct {
redirect string
code string
refreshToken string
redirect string
code string
refreshToken string
conflictBehavior string
expires time.Time
}
type optionFunc func(*options)
@@ -27,10 +31,27 @@ func WithRefreshToken(t string) Option {
})
}
// WithConflictBehavior 设置文件重名后的处理方式
func WithConflictBehavior(t string) Option {
return optionFunc(func(o *options) {
o.conflictBehavior = t
})
}
// WithExpires 设置过期时间
func WithExpires(t time.Time) Option {
return optionFunc(func(o *options) {
o.expires = t
})
}
func (f optionFunc) apply(o *options) {
f(o)
}
func newDefaultOption() *options {
return &options{}
return &options{
conflictBehavior: "fail",
expires: time.Now().UTC().Add(time.Duration(1) * time.Hour),
}
}