ast

package
v11.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2019 License: BSD-3-Clause, BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasAlias

func HasAlias(pt ParamType) (string, bool)

HasAlias returns any alias of the "pt" param type. If alias is empty or not found then it returns false as its second output argument.

func IsMaster

func IsMaster(pt ParamType) bool

IsMaster returns true if the "pt" param type is a master one.

func IsTrailing

func IsTrailing(pt ParamType) bool

IsTrailing returns true if the "pt" param type is a marked as trailing, which should accept more than one path segment when in the end.

Types

type AliasParamType

type AliasParamType interface {
	ParamType
	Alias() string
}

AliasParamType if implemeneted nad its `Alias()` returns a non-empty string then the param type can be written with that string literal too.

type MasterParamType

type MasterParamType interface {
	ParamType
	Master() bool
}

MasterParamType if implemented and its `Master()` returns true then empty type param will be translated to this param type. Also its functions will be available to the rest of the macro param type's funcs.

Only one Master is allowed.

type ParamFunc

type ParamFunc struct {
	Name string   // range
	Args []string // ["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 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 interface {
	// The name of the parameter type.
	// Indent should contain the characters for the parser.
	Indent() string
}

ParamType holds the necessary information about a parameter type for the parser to lookup for.

func GetMasterParamType

func GetMasterParamType(paramTypes ...ParamType) ParamType

GetMasterParamType accepts a list of ParamType and returns its master. If no `Master` specified: and len(paramTypes) > 0 then it will return the first one, otherwise it returns nil.

func LookupParamType

func LookupParamType(indentOrAlias string, paramTypes ...ParamType) (ParamType, bool)

LookupParamType accepts the string representation of a parameter type. Example: "string" "number" or "int" "long" or "int64" "uint8" "uint64" "boolean" or "bool" "alphabetical" "file" "path"

type TrailingParamType

type TrailingParamType interface {
	ParamType
	Trailing() bool
}

TrailingParamType if implemented and its `Trailing()` returns true then it should be declared at the end of a route path and can accept any trailing path segment as one parameter.

Jump to

Keyboard shortcuts

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