Fetch the repository succeeded.
package coauth
import (
"time"
"gitee.com/shishshinedone/coauth/coauth_core"
)
type Option func(o *coauth_core.Options)
func WithTimeout(value time.Duration) Option {
return func(o *coauth_core.Options) {
o.Timeout = value
}
}
type version string
const (
VersionOriginal version = coauth_core.VersionOriginal
)
func WithVersion(value version) Option {
return func(o *coauth_core.Options) {
o.Version = string(value)
}
}
type mode int
const (
ModeClient mode = coauth_core.ModeClient
ModePassword mode = coauth_core.ModePassword
)
func WithMode(value mode) Option {
return func(o *coauth_core.Options) {
o.Mode = int(value)
}
}
// GrantTypePassword模式有效
func WithGrantUsername(value string) Option {
return func(o *coauth_core.Options) {
o.GrantUsername = value
}
}
// GrantTypePassword模式有效
func WithGrantPassword(value string) Option {
return func(o *coauth_core.Options) {
o.GrantPassword = value
}
}
type scope string
const (
ScopeRead scope = coauth_core.ScopeRead
ScopeReadWrite scope = coauth_core.ScopeReadWrite
)
func WithScope(value scope) Option {
return func(o *coauth_core.Options) {
o.Scope = string(value)
}
}
type Coauth coauth_core.Coauth
func NewCoauth(addr, username, password string, optionArray ...Option) Coauth {
options := &coauth_core.Options{
Version: coauth_core.VersionOriginal,
Mode: coauth_core.ModeClient,
Scope: coauth_core.ScopeReadWrite,
}
for _, option := range optionArray {
option(options)
}
return coauth_core.NewCoauth(addr, username, password, options)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。