init
This commit is contained in:
23
logic/auth/auth.go
Normal file
23
logic/auth/auth.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package auth
|
||||
|
||||
import "time"
|
||||
|
||||
var execAuth = make(map[string]CreateFunc)
|
||||
|
||||
type CreateFunc func(url string, timeout time.Duration) Auth
|
||||
|
||||
func Register(name string, exec CreateFunc) {
|
||||
execAuth[name] = exec
|
||||
}
|
||||
|
||||
func Load(name string) (CreateFunc, error) {
|
||||
exec, ok := execAuth[name]
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return exec, nil
|
||||
}
|
||||
|
||||
type Auth interface {
|
||||
DoAuth(token string) (string, error)
|
||||
}
|
||||
Reference in New Issue
Block a user