Documentation
¶
Index ¶
- Variables
- func Addon(key string) ([]byte, error)
- func AddonAll() [][]byte
- func AddonExists(key string) bool
- func Backup(res http.ResponseWriter) error
- func CacheControl(next http.Handler) http.HandlerFunc
- func Close()
- func Config(key string) ([]byte, error)
- func ConfigAll() ([]byte, error)
- func ConfigCache(key string) interface{}
- func Content(target string) ([]byte, error)
- func ContentAll(namespace string) [][]byte
- func ContentBySlug(slug string) (string, []byte, error)
- func CurrentUser(req *http.Request) ([]byte, error)
- func DeleteAddon(key string) error
- func DeleteContent(target string, data url.Values) error
- func DeleteIndex(namespace, key string) error
- func DeleteUser(email string) error
- func DropIndex(namespace string) error
- func Index(namespace, key string) ([]byte, error)
- func Init()
- func InvalidateCache() error
- func LoadCacheConfig() error
- func NewEtag() string
- func PutConfig(key string, value interface{}) error
- func Query(namespace string, opts QueryOptions) (int, [][]byte)
- func RecoveryKey(email string) (string, error)
- func SetAddon(data url.Values, kind interface{}) error
- func SetConfig(data url.Values) error
- func SetContent(target string, data url.Values) (int, error)
- func SetIndex(namespace, key string, value interface{}) error
- func SetRecoveryKey(email string) (string, error)
- func SetUser(usr *user.User) (int, error)
- func SortContent(namespace string)
- func SystemInitComplete() bool
- func UpdateUser(usr, updatedUsr *user.User) error
- func User(email string) ([]byte, error)
- func UserAll() ([][]byte, error)
- type QueryOptions
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoAddonExists indicates that there was not addon found in the db ErrNoAddonExists = errors.New("No addon exists.") )
var ErrNoUserExists = errors.New("Error. No user exists.")
ErrNoUserExists is used for the db to report to admin user of non-existing user
var ErrUserExists = errors.New("Error. User exists.")
ErrUserExists is used for the db to report to admin user of existing user
Functions ¶
func Addon ¶
Addon looks for an addon by its addon_reverse_dns as the key and returns the []byte as json representation of an addon
func AddonExists ¶
AddonExists checks if there is an existing addon stored. The key is an the value at addon_reverse_dns
func Backup ¶
func Backup(res http.ResponseWriter) error
Backup writes a snapshot of the system.db database to an HTTP response
func CacheControl ¶
func CacheControl(next http.Handler) http.HandlerFunc
CacheControl sets the default cache policy on static asset responses
func Close ¶
func Close()
Close exports the abillity to close our db file. Should be called with defer after call to Init() from the same place.
func ConfigCache ¶
func ConfigCache(key string) interface{}
ConfigCache is a in-memory cache of the Configs for quicker lookups 'key' is the JSON tag associated with the config field
func Content ¶
Content retrives one item from the database. Non-existent values will return an empty []byte The `target` argument is a string made up of namespace:id (string:int)
func ContentAll ¶
ContentAll retrives all items from the database within the provided namespace
func ContentBySlug ¶
ContentBySlug does a lookup in the content index to find the type and id of the requested content. Subsequently, issues the lookup in the type bucket and returns the the type and data at that ID or nil if nothing exists.
func CurrentUser ¶
CurrentUser extracts the user from the request data and returns the current user from the db
func DeleteAddon ¶
DeleteAddon removes an addon from the db by its key, the addon_reverse_dns
func DeleteContent ¶
DeleteContent removes an item from the database. Deleting a non-existent item will return a nil error.
func DeleteIndex ¶
DeleteIndex removes the key and value from the namespace provided and will return an error if it fails. It will return nil if there was no key/value in the index to delete.
func DeleteUser ¶
DeleteUser deletes a user from the db by email
func Init ¶
func Init()
Init creates a db connection, initializes db with required info, sets secrets
func InvalidateCache ¶
func InvalidateCache() error
InvalidateCache sets a new Etag for http responses
func LoadCacheConfig ¶
func LoadCacheConfig() error
LoadCacheConfig loads the config into a cache to be accessed by ConfigCache()
func Query ¶
func Query(namespace string, opts QueryOptions) (int, [][]byte)
Query retrieves a set of content from the db based on options and returns the total number of content in the namespace and the content
func RecoveryKey ¶
RecoveryKey gets a previously set recovery key to verify an email address submitted in order to recover/reset an account password
func SetAddon ¶
SetAddon stores the values of an addon into the __addons bucket with a the `addon_reverse_dns` field used as the key. `kind` is the interface{} type for the provided addon (as in the result of calling addon.Types[id])
func SetContent ¶
SetContent inserts or updates values in the database. The `target` argument is a string made up of namespace:id (string:int)
func SetIndex ¶
SetIndex sets a key/value pair within the namespace provided and will return an error if it fails
func SetRecoveryKey ¶
SetRecoveryKey generates and saves a random secret key to verify an email address submitted in order to recover/reset an account password
func SortContent ¶
func SortContent(namespace string)
SortContent sorts all content of the type supplied as the namespace by time, in descending order, from most recent to least recent Should be called from a goroutine after SetContent is successful
func SystemInitComplete ¶
func SystemInitComplete() bool
SystemInitComplete checks if there is at least 1 admin user in the db which would indicate that the system has been configured to the minimum required.
func UpdateUser ¶
UpdateUser sets key:value pairs in the db for existing user settings
Types ¶
type QueryOptions ¶
QueryOptions holds options for a query