Documentation
¶
Index ¶
- Constants
- Variables
- type CacheCodeStore
- type CodeSender
- type CodeStore
- type CodeValidator
- type ExpireCode
- type MemoryCodeStore
- type RedisCodeStore
- func (s *RedisCodeStore) CreateCode(id string, scene string, code string) error
- func (s *RedisCodeStore) CreateRequest(id string) error
- func (s *RedisCodeStore) GetCode(id string, scene string, remove bool) (string, bool)
- func (s *RedisCodeStore) RedisKey(name string, key string, scene string) string
- func (s *RedisCodeStore) RemoveCode(id string, scene string)
- type Validator
- func (v *Validator) CheckCode(target CodeValidator, dest string, scene string, code string) bool
- func (v *Validator) CreateRandCode() string
- func (v *Validator) GenerateCode(target CodeValidator, dest string, scene string) (string, error)
- func (v *Validator) GetSender() CodeSender
- func (v *Validator) GetStore() CodeStore
- func (v *Validator) GetVerificationCode(target CodeValidator, dest string, scene string) (string, bool)
Constants ¶
View Source
const ( CODE_REDIS_KEY_PREFIX = "code:phone:" REQUEST_REDIS_KEY_PREFIX = "request:phone:" )
Variables ¶
View Source
var Nop = nop{}
Functions ¶
This section is empty.
Types ¶
type CacheCodeStore ¶
type CacheCodeStore struct {
CodeStore
// contains filtered or unexported fields
}
func CreateCacheCodeStore ¶
func CreateCacheCodeStore(config *config.CodeStoreSetting) (*CacheCodeStore, error)
func (*CacheCodeStore) CreateCode ¶
func (s *CacheCodeStore) CreateCode(id string, scene string, code string) error
func (*CacheCodeStore) CreateRequest ¶
func (s *CacheCodeStore) CreateRequest(id string) error
func (*CacheCodeStore) RemoveCode ¶
func (s *CacheCodeStore) RemoveCode(id string, scene string)
type CodeSender ¶
type CodeStore ¶
type CodeStore interface {
CreateRequest(id string) error
CreateCode(id string, scene string, code string) error
GetCode(id string, scene string, remove bool) (string, bool)
RemoveCode(id string, scene string)
}
func CreateRedisCodeStore ¶
func CreateRedisCodeStore(config *config.CodeStoreSetting) (result CodeStore, err error)
type CodeValidator ¶
type CodeValidator interface {
GetStore() CodeStore
GetSender() CodeSender
GenerateCode(target CodeValidator, dest string, scene string) (string, error)
GetVerificationCode(target CodeValidator, dest string, scene string) (string, bool)
CheckCode(target CodeValidator, dest string, scene string, code string) bool
}
func NewValidator ¶
func NewValidator(sender CodeSender, store CodeStore) CodeValidator
type ExpireCode ¶
type MemoryCodeStore ¶
type MemoryCodeStore struct {
// contains filtered or unexported fields
}
func CreateMemoryCodeStore ¶
func CreateMemoryCodeStore(config *config.CodeStoreSetting) (*MemoryCodeStore, error)
func (*MemoryCodeStore) CreateCode ¶
func (s *MemoryCodeStore) CreateCode(id string, scene string, code string) error
func (*MemoryCodeStore) CreateRequest ¶
func (s *MemoryCodeStore) CreateRequest(id string) error
func (*MemoryCodeStore) RemoveCode ¶
func (s *MemoryCodeStore) RemoveCode(phone string, scene string)
type RedisCodeStore ¶
type RedisCodeStore struct {
// contains filtered or unexported fields
}
func (*RedisCodeStore) CreateCode ¶
func (s *RedisCodeStore) CreateCode(id string, scene string, code string) error
func (*RedisCodeStore) CreateRequest ¶
func (s *RedisCodeStore) CreateRequest(id string) error
func (*RedisCodeStore) RedisKey ¶
func (s *RedisCodeStore) RedisKey(name string, key string, scene string) string
func (*RedisCodeStore) RemoveCode ¶
func (s *RedisCodeStore) RemoveCode(id string, scene string)
type Validator ¶
type Validator struct {
Store CodeStore
Sender CodeSender
}
func (*Validator) GenerateCode ¶
func (*Validator) GetSender ¶
func (v *Validator) GetSender() CodeSender
func (*Validator) GetVerificationCode ¶
Click to show internal directories.
Click to hide internal directories.