actions

package
v1.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DQGLogger = log.New(os.Stdout, "DynamicQuerysGo [*] ", log.LstdFlags)

DQGLogger - Logger for DynamicQuerysGo processes (can be stdout or a io.writer to a file)

View Source
var FuncsStorage = FuncMap{

	"ReverseString":        funcendpoints.ReverseString,
	"ReverseStringBool":    funcendpoints.ReverseStringBool,
	"TakeAnInterfaceArray": funcendpoints.TakeAInterfaceArray,
	"TakeAMap":             funcendpoints.TakeAMap,
}

FuncsStorage -

Functions

func CallFunc

func CallFunc(funcName string, params []interface{}) (interface{}, error)

CallFunc - Calls the function with by the name specified in funcName

func CheckGivenParams

func CheckGivenParams(params []interface{}, numParams int) error

CheckGivenParams - checks if the number of parmeters is the correct amount.

func CheckRequestIsAction

func CheckRequestIsAction(action string) error

CheckRequestIsAction - Verifys the request content contains an action

func CheckTypeAndConvert

func CheckTypeAndConvert(word string) (interface{}, error)

CheckTypeAndConvert - Takes a string and compares it to a number of regex patterns, each representing golang data types,

if the pattern and string match, the string will be converted to the represented data type.
The order of regex comparisson is important in some cases, such as in strings, json-like strings ("{\"name\":\"Golang\"}").

func GetFunctionParamsNum

func GetFunctionParamsNum(function reflect.Value) (int, error)

GetFunctionParamsNum - Gets the given function number of parameters, and returns it or an error.

func Handler

func Handler(rw http.ResponseWriter, r *http.Request)

Handler - Handles all of the requests coming into the server

func ParseParamsIntoRVArray

func ParseParamsIntoRVArray(params []interface{}) ([]reflect.Value, error)

ParseParamsIntoRVArray - Gets values from the params array, and puts their reflect value insside a []reflect.Value, and returns it.

func RunFunctionsGetReturns

func RunFunctionsGetReturns(functionCalMap []Endpoint) (map[string]interface{}, error)

RunFunctionsGetReturns - Runs the given functions in []FunctionPath, and returns the resulting function-call values. Returns the called functions results as map[string]interface{}, and an error (nil if successfull)

Types

type BodyContents

type BodyContents struct {
	ActionBody     string     // Body of the action
	Authentication [][]string // JWT auth tokens
	FuncCalls      [][]string // Function names passed in the schema
	FuncArgs       [][]string // Passed params in the schema
	FuncsContent   []string   // Content of the " funcs: " section of the schema
}

BodyContents - Represents the extende structure of the action body

func ParseActionContents

func ParseActionContents(request string) (BodyContents, error)

ParseActionContents - Separates the action into its dedicated content parts

type Endpoint

type Endpoint struct {
	FuncName string        // Function name to call
	Params   []interface{} // Parameters to be passed into the function
}

Endpoint - Represent the function called in the action schema, its name and parameters

func ParseActionBody

func ParseActionBody(regex string, actionContents BodyContents) ([]Endpoint, error)

ParseActionBody - Parsses the action body text into usable data

type FuncMap

type FuncMap map[string]interface{}

FuncMap - Map with the available functions to call

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL