feat: complete login
This commit is contained in:
@@ -5,18 +5,6 @@ import (
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
o := opt.New(opts...)
|
||||
var config Config
|
||||
if err := o.UnmarshalConfig(&config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return container.Container.Provide(func() (*Config, error) {
|
||||
return &config, nil
|
||||
}, o.DiOptions()...)
|
||||
}
|
||||
|
||||
const DefaultPrefix = "WeChat"
|
||||
|
||||
func DefaultProvider() container.ProviderContainer {
|
||||
@@ -28,6 +16,28 @@ func DefaultProvider() container.ProviderContainer {
|
||||
}
|
||||
}
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
o := opt.New(opts...)
|
||||
var config Config
|
||||
if err := o.UnmarshalConfig(&config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return container.Container.Provide(func() (*Config, *Client, error) {
|
||||
httpClient := DefaultClient
|
||||
if config.DevMode {
|
||||
httpClient = httpClient.DevMode()
|
||||
}
|
||||
return &config, New(
|
||||
WithAppID(config.AppID),
|
||||
WithAppSecret(config.AppSecret),
|
||||
WithAESKey(config.EncodingAESKey),
|
||||
WithToken(config.Token),
|
||||
WithClient(httpClient),
|
||||
), nil
|
||||
}, o.DiOptions()...)
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
AppID string
|
||||
AppSecret string
|
||||
|
||||
Reference in New Issue
Block a user