ast

package
v8.5.4+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParamFuncArgToInt

func ParamFuncArgToInt(a ParamFuncArg) (int, error)

ParamFuncArgToInt converts and returns any type of "a", to an integer.

Types

type ParamFunc

type ParamFunc struct {
	Name string         // range
	Args []ParamFuncArg // [1,5]
}

ParamFunc holds the name of a parameter's function and its arguments (values) A param func is declared with: {param:int range(1,5)}, the range is the param function name the 1 and 5 are the two param function arguments range(1,5)

type ParamFuncArg

type ParamFuncArg interface{}

ParamFuncArg represents a single parameter function's argument

type ParamStatement

type ParamStatement struct {
	Src       string      // the original unparsed source, i.e: {id:int range(1,5) else 404}
	Name      string      // id
	Type      ParamType   // int
	Funcs     []ParamFunc // range
	ErrorCode int         // 404
}

ParamStatement is a struct which holds all the necessary information about a macro parameter. It holds its type (string, int, alphabetical, file, path), its source ({param:type}), its name ("param"), its attached functions by the user (min, max...) and the http error code if that parameter failed to be evaluated.

type ParamType

type ParamType uint8

ParamType is a specific uint8 type which holds the parameter types' type.

const (
	// ParamTypeUnExpected is an unexpected parameter type.
	ParamTypeUnExpected ParamType = iota
	// ParamTypeString 	is the string type.
	// If parameter type is missing then it defaults to String type.
	// Allows anything
	// Declaration: /mypath/{myparam:string} or /mypath{myparam}
	ParamTypeString
	// ParamTypeInt is the integer, a number type.
	// Allows only positive numbers (0-9)
	// Declaration: /mypath/{myparam:int}
	ParamTypeInt
	// ParamTypeLong is the integer, a number type.
	// Allows only positive numbers (0-9)
	// Declaration: /mypath/{myparam:long}
	ParamTypeLong
	// ParamTypeBoolean is the bool type.
	// Allows only "1" or "t" or "T" or "TRUE" or "true" or "True"
	// or "0" or "f" or "F" or "FALSE" or "false" or "False".
	// Declaration: /mypath/{myparam:boolean}
	ParamTypeBoolean
	// ParamTypeAlphabetical is the  alphabetical/letter type type.
	// Allows letters only (upper or lowercase)
	// Declaration:  /mypath/{myparam:alphabetical}
	ParamTypeAlphabetical
	// ParamTypeFile  is the file single path type.
	// Allows:
	// letters (upper or lowercase)
	// numbers (0-9)
	// underscore (_)
	// dash (-)
	// point (.)
	// no spaces! or other character
	// Declaration: /mypath/{myparam:file}
	ParamTypeFile
	// ParamTypePath is the multi path (or wildcard) type.
	// Allows anything, should be the last part
	// Declaration: /mypath/{myparam:path}
	ParamTypePath
)

func LookupParamType

func LookupParamType(ident string) ParamType

LookupParamType accepts the string representation of a parameter type. Available: "string" "int" "alphabetical" "file" "path"

Jump to

Keyboard shortcuts

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