cleanup: move init funcs to the top of the source

We make sure they're not hiding at the bottom or in the middle
which makes debugging an utter nightmare!

Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
Milos Gajdos
2023-11-28 06:50:48 +00:00
parent d9abc517e8
commit d8ff41a344
14 changed files with 203 additions and 201 deletions

View File

@@ -45,6 +45,16 @@ var (
ErrAuthenticationFailure = errors.New("authentication failure")
)
// InitFunc is the type of an AccessController factory function and is used
// to register the constructor for different AccesController backends.
type InitFunc func(options map[string]interface{}) (AccessController, error)
var accessControllers map[string]InitFunc
func init() {
accessControllers = make(map[string]InitFunc)
}
// UserInfo carries information about
// an autenticated/authorized client.
type UserInfo struct {
@@ -104,16 +114,6 @@ type CredentialAuthenticator interface {
AuthenticateUser(username, password string) error
}
// InitFunc is the type of an AccessController factory function and is used
// to register the constructor for different AccesController backends.
type InitFunc func(options map[string]interface{}) (AccessController, error)
var accessControllers map[string]InitFunc
func init() {
accessControllers = make(map[string]InitFunc)
}
// Register is used to register an InitFunc for
// an AccessController backend with the given name.
func Register(name string, initFunc InitFunc) error {