lib

package
v0.0.0-...-26b8db2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ModuleDirPath is modules directory of project
	ModuleDirPath string
	// HandlerDirPath is handlers directory of project
	HandlerDirPath string
	// EventDirPath is events directory of project
	EventDirPath string
	// FileDirPath :
	FileDirPath string
	// PackageDirPath is the directory that contains 3rd party modules
	PackageDirPath string
	// BasePath is the main directory of application
	BasePath string
)

Functions

func CheckForArgumentCount

func CheckForArgumentCount(vm *otto.Otto, call otto.FunctionCall, want int)

CheckForArgumentCount checks for argument count. if got and want values are not equal, panic

func GetEmptyObject

func GetEmptyObject(vm *otto.Otto) *otto.Object

GetEmptyObject returns {} (empty javascript object)

func GetQueryValues

func GetQueryValues(queryString string) map[string]interface{}

GetQueryValues :

func ParseURLFromFilename

func ParseURLFromFilename(filename string) (string, string, error)

ParseURLFromFilename take file name of script. returns URL and method if it's defined in filename,

otherwise returns ALL method

i.e "/test/file.js" -> ("/test/file", "ALL")

"/test/file.post.js" -> ("test/file", "POST")
"/test/folder/index.js" ("test/folder","ALL")

func ToIntFromValue

func ToIntFromValue(value otto.Value, defaultVal int) int

ToIntFromValue parses a value to integer. if an error occured, returns given default value

func ToStringFromVM

func ToStringFromVM(vm *otto.Otto, key, defaultVal string) string

ToStringFromVM parse string from vm

func ToStringFromValue

func ToStringFromValue(val otto.Value, defaultVal string) string

ToStringFromValue parses a value to string

func ToValueFromString

func ToValueFromString(str string) otto.Value

ToValueFromString must parse value from string

func UpdateEnginePathVars

func UpdateEnginePathVars(baseDir string)

UpdateEnginePathVars update path variables depends on given base dir

Types

type Bundle

type Bundle struct {
	Program  *ast.Program
	Filename ProgramPath
}

Bundle is parsed javascript files ready to execution

func NewBundle

func NewBundle(program *ast.Program, filename ProgramPath) *Bundle

NewBundle creates new bundle

type JSFunc

type JSFunc func(call otto.FunctionCall) otto.Value

JSFunc presents javascript function

type ProgramPath

type ProgramPath string

ProgramPath is path of a progrm

func NewProgramPath

func NewProgramPath(path string) ProgramPath

NewProgramPath returns a new ProgramPath

type URLPath

type URLPath struct {
	// contains filtered or unexported fields
}

URLPath represent url path of request it is useful for checking handler paths

func NewURLPath

func NewURLPath(s string) *URLPath

NewURLPath returns new url path

func (URLPath) Check

func (p URLPath) Check(url string) bool

Check checks URLPath satisfy url or not

func (URLPath) GetURLParams

func (p URLPath) GetURLParams(url string) map[string]string

GetURLParams parse url parameter from urlPart

func (URLPath) Raw

func (p URLPath) Raw() string

Raw return raw string of url path

Jump to

Keyboard shortcuts

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