Documentation ¶
Overview ¶
Currently this package only contains the definitions for various plugin types. It is planned to contain a plugin manager interface and an implementation of one to make simple "startup scripts" listing plugins.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Version string
Functions ¶
This section is empty.
Types ¶
type APIPlugin ¶
type APIPlugin interface { Plugin // A router mounted on /. Generally, keep API extensions inside of // `/api/`; this interface gives / for well-known URIs, etc. Route(chi.Router) }
A plugin with an API router.
type CrossPlugin ¶
type CrossPlugin interface { Plugin // Called after all other plugins have been initialized. Extend(map[string]Plugin) error }
A plugin that extends another plugin, or just has access to the plugin map.
type DatabasePlugin ¶ added in v0.0.2
A plugin with managed file-based SQL migrations. Migrations() returns a map of Unix timestamps to Go migrations. Any migrations since the last are each executed until one throws an error. On error, Destroy() is called, the database is restored, and an error is logged.
type Manager ¶
type Manager interface { // On error, returns the index of the plugin erroring and the error // received, or “(-1, nil)“ if all plugins initialized successfully. AddPlugins(...Plugin) (int, error) AddPluginFile(filename string) error GetPluginMap() map[string]Plugin // Finishishes initializing each plugin, specifically by passing the // plugin map to CrossPlugins. Finalize() // Starts listening. If the Server pointer is nil, Listen will use the // implementation default. Implementors should not modify a passed // Server except its Handler. Listen(*http.Server) // Shuts down the “http.Server“ in Listen() and calls Destroy() on // each plugin. Returns any error in shutting down, for instance from // “http.Server.Shutdown()“. Shutdown() error }
func GetDefaultManager ¶
Returns a Manager using “config/hub.yml“ to set up.
type Plugin ¶
type Plugin interface { Init(*log.Logger, PluginParams) error // Returns the D-Bus or Java–style name for the plugin. Must not rely // on an earlier Init() call. DBusName() string // Function to close connections, end requests, etc. Destroy() }
A plugin.
There is an example plugin in the package codeberg.org/libreedu/hub/plugins/example which simply registers the endpoint `/api/example-plugin` and returns the string "Hello, world!"
Plugins should use package-scope variables, if they must work with `-buildmode plugin`, because exported shared object types cannot maintain state.
type PluginParams ¶
type PluginParams struct { // A struct containing a bun DB, generally Postgres or another system // supporting PL/pgSQL. If you prefer, you can access a `*sql.DB` at // `plugin.DB.DB.DB`. // // Please be mindful of other plugins and contain your plugin's data // in its own Postgres schema. DB *DB // A file handle for a config file. If there is no configuration file, // this is set to nil. This is owned by the manager - the file will be // closed after the AddPlugins function (when Init is called) ends. ConfigHandle io.ReadSeekCloser }
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
internal
|
|
This package contains useful middleware functions.
|
This package contains useful middleware functions. |
The `models` module provides core database types like User.
|
The `models` module provides core database types like User. |
plugins
|
|
auth_oidc
Use codeberg.org/libreedu/hub/plugins/auth_oidc/import in launch script
|
Use codeberg.org/libreedu/hub/plugins/auth_oidc/import in launch script |
auth_oidc/import
(Incomplete) Plugin auth_oidc adds support for OpenID Connect Discovery and authentication.
|
(Incomplete) Plugin auth_oidc adds support for OpenID Connect Discovery and authentication. |
auth_userpass
Use codeberg.org/libreedu/hub/plugins/auth_userpass/import in launch script
|
Use codeberg.org/libreedu/hub/plugins/auth_userpass/import in launch script |
auth_userpass/import
This plugin adds support for logging in with username, password, and extensible other factors.
|
This plugin adds support for logging in with username, password, and extensible other factors. |
avatar
Use codeberg.org/libreedu/hub/plugins/avatar/import in launch script
|
Use codeberg.org/libreedu/hub/plugins/avatar/import in launch script |
avatar/import
This plugin allows viewing and uploading user avatars.
|
This plugin allows viewing and uploading user avatars. |
core
Use codeberg.org/libreedu/hub/plugins/core/import in launch script
|
Use codeberg.org/libreedu/hub/plugins/core/import in launch script |
example
Use codeberg.org/libreedu/hub/plugins/example/import in launch script
|
Use codeberg.org/libreedu/hub/plugins/example/import in launch script |