Documentation
¶
Index ¶
- Variables
- func BuildWhereClause(where map[string]interface{}) (string, []interface{}, error)
- func FormatToContext(input map[string]interface{}) (map[string]string, error)
- type CallFunctionRequest
- type CallFunctionResponse
- type DBPlugin
- type DBPluginPlugin
- type DBPluginRPC
- func (g *DBPluginRPC) CallFunction(userID, funcName string, data map[string]interface{}, ...) (interface{}, error)
- func (g *DBPluginRPC) InitConnection(uri string) error
- func (g *DBPluginRPC) TableCreate(userID, table string, data []map[string]interface{}, ...) ([]map[string]interface{}, error)
- func (g *DBPluginRPC) TableDelete(userID, table string, where map[string]interface{}, ctx map[string]interface{}) (int, error)
- func (g *DBPluginRPC) TableGet(userID, table string, selectFields []string, where map[string]interface{}, ...) ([]map[string]interface{}, error)
- func (g *DBPluginRPC) TableUpdate(userID, table string, data map[string]interface{}, ...) (int, error)
- type DBPluginRPCServer
- func (s *DBPluginRPCServer) CallFunction(req CallFunctionRequest, resp *CallFunctionResponse) error
- func (s *DBPluginRPCServer) InitConnection(req InitConnectionRequest, resp *InitConnectionResponse) error
- func (s *DBPluginRPCServer) TableCreate(req TableCreateRequest, resp *TableCreateResponse) error
- func (s *DBPluginRPCServer) TableDelete(req TableDeleteRequest, resp *TableDeleteResponse) error
- func (s *DBPluginRPCServer) TableGet(req TableGetRequest, resp *TableGetResponse) error
- func (s *DBPluginRPCServer) TableUpdate(req TableUpdateRequest, resp *TableUpdateResponse) error
- type InitConnectionRequest
- type InitConnectionResponse
- type TableCreateRequest
- type TableCreateResponse
- type TableDeleteRequest
- type TableDeleteResponse
- type TableGetRequest
- type TableGetResponse
- type TableUpdateRequest
- type TableUpdateResponse
Constants ¶
This section is empty.
Variables ¶
var Handshake = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "EASYREST_PLUGIN",
MagicCookieValue: "easyrest",
}
Handshake configuration for plugin security.
var Version = "v0.1.1"
Functions ¶
func BuildWhereClause ¶
BuildWhereClause constructs a SQL WHERE clause from a given where map. The where map is expected to be in the form:
{ "field": {"=": value}, ... }
It returns the SQL string (starting with " WHERE ") and the list of arguments. This is the original logic.
func FormatToContext ¶
FormatToContext flattens an arbitrarily nested map into a flat map with keys joined by underscores. It replaces dots and dashes with underscores and converts keys to lowercase. For arrays, it uses the index as part of the key. It also validates that the final values do not contain dangerous characters.
Types ¶
type CallFunctionRequest ¶
type CallFunctionResponse ¶
type CallFunctionResponse struct {
Result interface{}
Error string
}
type DBPlugin ¶
type DBPlugin interface {
InitConnection(uri string) error
TableGet(userID, table string, selectFields []string, where map[string]interface{},
ordering []string, groupBy []string, limit, offset int, ctx map[string]interface{}) ([]map[string]interface{}, error)
TableCreate(userID, table string, data []map[string]interface{}, ctx map[string]interface{}) ([]map[string]interface{}, error)
TableUpdate(userID, table string, data map[string]interface{}, where map[string]interface{}, ctx map[string]interface{}) (int, error)
TableDelete(userID, table string, where map[string]interface{}, ctx map[string]interface{}) (int, error)
CallFunction(userID, funcName string, data map[string]interface{}, ctx map[string]interface{}) (interface{}, error)
}
DBPlugin – interface for DB access plugins.
type DBPluginPlugin ¶
type DBPluginPlugin struct {
Impl DBPlugin
}
DBPluginPlugin wraps the DBPlugin implementation for go-plugin.
type DBPluginRPC ¶
type DBPluginRPC struct {
// contains filtered or unexported fields
}
DBPluginRPC is the client wrapper.
func (*DBPluginRPC) CallFunction ¶
func (g *DBPluginRPC) CallFunction(userID, funcName string, data map[string]interface{}, ctx map[string]interface{}) (interface{}, error)
func (*DBPluginRPC) InitConnection ¶
func (g *DBPluginRPC) InitConnection(uri string) error
func (*DBPluginRPC) TableCreate ¶
func (*DBPluginRPC) TableDelete ¶
func (*DBPluginRPC) TableUpdate ¶
type DBPluginRPCServer ¶
type DBPluginRPCServer struct {
Impl DBPlugin
}
DBPluginRPCServer implements the server side RPC.
func (*DBPluginRPCServer) CallFunction ¶
func (s *DBPluginRPCServer) CallFunction(req CallFunctionRequest, resp *CallFunctionResponse) error
func (*DBPluginRPCServer) InitConnection ¶
func (s *DBPluginRPCServer) InitConnection(req InitConnectionRequest, resp *InitConnectionResponse) error
func (*DBPluginRPCServer) TableCreate ¶
func (s *DBPluginRPCServer) TableCreate(req TableCreateRequest, resp *TableCreateResponse) error
func (*DBPluginRPCServer) TableDelete ¶
func (s *DBPluginRPCServer) TableDelete(req TableDeleteRequest, resp *TableDeleteResponse) error
func (*DBPluginRPCServer) TableGet ¶
func (s *DBPluginRPCServer) TableGet(req TableGetRequest, resp *TableGetResponse) error
func (*DBPluginRPCServer) TableUpdate ¶
func (s *DBPluginRPCServer) TableUpdate(req TableUpdateRequest, resp *TableUpdateResponse) error
type InitConnectionRequest ¶
type InitConnectionRequest struct {
URI string
}
RPC request/response structures.
type InitConnectionResponse ¶
type InitConnectionResponse struct {
Error string
}