Documentation ¶
Overview ¶
Package registry provides a central way to register and use all available saving backends and plugins. All options should be registered prior to the program starting, normally through init().
Index ¶
- func ComparePasswords(method, password, truth string) (bool, error)
- func PasswordMethodExists(method string) bool
- func RegisterDataSafe(t DataSafe, name string) error
- func RegisterPasswordMethod(method PasswordMethod, name string) error
- func RegisterPlugin(f PluginFactory, name string) error
- type AlreadyRegisteredError
- type Announcement
- type DataSafe
- type PasswordMethod
- type Plugin
- type PluginFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComparePasswords ¶
ComparePasswords compares a password to a 'truth'. The bool represents whether comparison is successful. Error is returned if there is any error during computation. You can savely use it in parallel.
func PasswordMethodExists ¶
RegisterPasswordMethod returns whether the password method is known. You can savely use it in parallel.
func RegisterDataSafe ¶
RegisterDataSafe registeres a data safe. The name of the data safe is used as an identifier and must be unique. You can savely use it in parallel.
func RegisterPasswordMethod ¶
func RegisterPasswordMethod(method PasswordMethod, name string) error
RegisterPasswordMethod registeres a password method. The name of the password method is used as an identifier and must be unique. You can savely use it in parallel.
func RegisterPlugin ¶
func RegisterPlugin(f PluginFactory, name string) error
RegisterPlugin registeres a plugin. The name of the plugin is used as an identifier and must be unique. You can savely use it in parallel.
Types ¶
type AlreadyRegisteredError ¶
type AlreadyRegisteredError string
AlreadyRegisteredError represents an error where an option is already registeres
func (AlreadyRegisteredError) Error ¶
func (a AlreadyRegisteredError) Error() string
Error returns the error description
type Announcement ¶
Announcement represents a single announcement. It has two main parts: a short header (something like a short summary) and the actual message. Time contains the publication time of the announcement.
type DataSafe ¶
type DataSafe interface { InitialiseDatasafe(config []byte) error GetConfig(key, plugin string) ([]byte, error) SetConfig(key, plugin string, config []byte) error SaveAnnouncement(key string, a Announcement) (id string, err error) GetAnnouncement(key, id string) (Announcement, error) GetAllAnnouncements(key string) ([]Announcement, error) GetAnnouncementKeys(key string) ([]string, error) }
DataSafe represents a backend for save storage of questionnaire results. The keys of the announcement should be kept in the order they arrive.
CurrentDataSafe holds the current data safe. It must be saved before loading any Plugin and never be changed after that.
func GetDataSafe ¶
GetDataSafe returns a data safe. The bool indicates whether it existed. You can only use it if the bool is true.
type PasswordMethod ¶
PasswordMethod enables to compare the password against different 'truth'. The truth might be plain text, a password hash or similar. Truth must contain every information needed to compare the password. The function must be callable in parallel at the same time. The bool represents whether comparison is successful. Error is returned if there is any error during computation.
type Plugin ¶
type Plugin interface { GetConfig() template.HTML ProcessConfigChange(r *http.Request) error NewAnnouncement(a Announcement, id string) }
Plugin represents an announcement plugin. All methods must be save to use in parallel.
type PluginFactory ¶
PluginFactory represents a function to generate a new Plugin. The Plugin loads its configuration from the DataSafe.
func GetPlugin ¶
func GetPlugin(name string) (PluginFactory, bool)
GetPlugin returns a plugin factory. The bool indicates whether it existed. You can only use it if the bool is true.