Documentation ¶
Index ¶
- Variables
- func ErrPlugin(err string, args ...interface{}) error
- func NewMiddleware(p *Plugin, h http.Handler) http.Handler
- func NoOverlay(db database.DB) database.DB
- func UnmarshalObjectMeta(r *http.Request, obj interface{}) error
- type Middleware
- type ObjectInfo
- type Plugin
- type PluginDB
- func (db *PluginDB) AdminDB() *database.AdminDB
- func (db *PluginDB) BasicRequest(method, api string, body io.Reader) error
- func (db *PluginDB) CanCreateObject(s *database.Object) error
- func (db *PluginDB) CreateApp(c *database.App) (string, string, error)
- func (db *PluginDB) CreateObject(s *database.Object) (string, error)
- func (db *PluginDB) CreateUser(u *database.User) error
- func (db *PluginDB) DelApp(id string) error
- func (db *PluginDB) DelObject(id string) error
- func (db *PluginDB) DelUser(name string) error
- func (db *PluginDB) DelUserSession(username, sessionid string) error
- func (db *PluginDB) Fire(e *events.Event)
- func (db *PluginDB) GetObjectShares(objectid string) (m map[string]*database.ScopeArray, err error)
- func (db *PluginDB) ID() string
- func (db *PluginDB) ListApps(o *database.ListAppOptions) ([]*database.App, error)
- func (db *PluginDB) ListObjects(o *database.ListObjectsOptions) ([]*database.Object, error)
- func (db *PluginDB) ListUserSessions(username string) (v []database.UserSession, err error)
- func (db *PluginDB) ListUsers(o *database.ListUsersOptions) ([]*database.User, error)
- func (db *PluginDB) NewRequest(method, path string, body io.Reader) (*http.Request, error)
- func (db *PluginDB) ReadApp(id string, o *database.ReadAppOptions) (*database.App, error)
- func (db *PluginDB) ReadObject(id string, o *database.ReadObjectOptions) (*database.Object, error)
- func (db *PluginDB) ReadUser(name string, o *database.ReadUserOptions) (*database.User, error)
- func (db *PluginDB) ReadUserPluginSettings(username string, plugin string) (v map[string]interface{}, err error)
- func (db *PluginDB) ReadUserSettings(username string) (v map[string]map[string]interface{}, err error)
- func (db *PluginDB) ShareObject(objectid, userid string, sa *database.ScopeArray) error
- func (db *PluginDB) StringRequest(method, api string, body io.Reader) (string, error)
- func (db *PluginDB) Type() database.DBType
- func (db *PluginDB) UnmarshalRequest(obj interface{}, method, api string, body io.Reader) error
- func (db *PluginDB) UnshareObject(objectid string) error
- func (db *PluginDB) UnshareObjectFromUser(objectid, userid string) error
- func (db *PluginDB) UpdateApp(c *database.App) error
- func (db *PluginDB) UpdateObject(s *database.Object) error
- func (db *PluginDB) UpdateUser(u *database.User) error
- func (db *PluginDB) UpdateUserPluginSettings(username string, plugin string, settings map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ErrUnimplemented = errors.New("unimplemented")
Functions ¶
func NoOverlay ¶
NoOverlay returns a copy of the database with all overlays removed if it is a PluginDB. This is needed for any queries that are run from object implementations
func UnmarshalObjectMeta ¶
UnmarshalObjectMeta extracts the meta portion from the object, unmarshalling it into the given object. This is because the meta portion of the object is base64 encoded in the X-Heedy-Meta header to avoid unnecessary read queries to the database.
Types ¶
type Middleware ¶
Middleware constructs a Heedy server context for an http handler, allowing to create API handlers compatible with the heedy builtin server. That is, a plugin that uses the middleware can in the future be embedded in Heedy without any changes.
func (*Middleware) ServeHTTP ¶
func (m *Middleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ObjectInfo ¶
type ObjectInfo struct { Type string ID string Owner string App string ModifiedDate *string Meta map[string]interface{} Access database.ScopeArray }
ObjectInfo holds the information sent from heedy as http headers about a object. These headers are only present in requests for object API
func GetObjectInfo ¶
func GetObjectInfo(r *http.Request) (*ObjectInfo, error)
GetObjectInfo prepares all object details that come in as part of a object request
func (*ObjectInfo) AsObject ¶
func (o *ObjectInfo) AsObject() string
AsObject returns the "As" of the object owner, be it a user or an app
type Plugin ¶
Plugin contains methods that can be used when generating golang heedy plugins it is the main interface with the main server
func Init ¶
Init is to be run right at the start of the plugin, and it can only be run once. It parses the information incoming from heedy, and prepares the relevant methods
func (*Plugin) AdminDB ¶
AdminDB returns the heedy adminsitrative database. Through the AdminDB, the plugin can make direct sql queries to the database. Be aware that the adminDB does not go through the heedy server at all - it operates directly upon the sql database. For this reason, it is recommended to use PluginDB for queries that can be handled by the heedy server, since the plugin version might not be exactly aligned with the server version, and it might cause compatibility issues. AdminDB is best used for raw sql queries to the database.
func (*Plugin) InitSQL ¶
func (p *Plugin) InitSQL(name string, version int, updater func(*database.AdminDB, *run.Info, run.BuiltinHelper, int) error) error
InitSQL initializes the plugin's sql portion
type PluginDB ¶
type PluginDB struct { P *Plugin Entity string Overlay int RequestID string // contains filtered or unexported fields }
func (*PluginDB) BasicRequest ¶
BasicRequest runs a basic query, and does not return the body unless there was an error
func (*PluginDB) CreateObject ¶
func (*PluginDB) DelUserSession ¶
func (*PluginDB) Fire ¶
Fire allows PluginDB to conform to the events.Handler interface, which is used to fire events
func (*PluginDB) GetObjectShares ¶
func (*PluginDB) ListObjects ¶
ListObjects lists the given objects
func (*PluginDB) ListUserSessions ¶
func (db *PluginDB) ListUserSessions(username string) (v []database.UserSession, err error)
func (*PluginDB) NewRequest ¶
func (*PluginDB) ReadObject ¶
func (*PluginDB) ReadUserPluginSettings ¶
func (*PluginDB) ReadUserSettings ¶
func (*PluginDB) ShareObject ¶
func (db *PluginDB) ShareObject(objectid, userid string, sa *database.ScopeArray) error