parser

package
v12.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// DefaultParamErrorCode is the default http error code, 404 not found,
	// per-parameter. An error code can be set via
	// the "else" keyword inside a route's path.
	DefaultParamErrorCode = 404
)

Variables

This section is empty.

Functions

func Parse

func Parse(fullpath string, paramTypes []ast.ParamType) ([]*ast.ParamStatement, error)

Parse takes a route "fullpath" and returns its param statements or an error if failed.

Types

type ParamParser

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

ParamParser is the parser which is being used by the Parse function to parse path segments one by one and return their parsed parameter statements (param name, param type its functions and the inline route's functions).

func NewParamParser

func NewParamParser(src string) *ParamParser

NewParamParser receives a "src" of a single parameter and returns a new ParamParser, ready to Parse.

func (ParamParser) Error

func (p ParamParser) Error() error

func (*ParamParser) Parse

func (p *ParamParser) Parse(paramTypes []ast.ParamType) (*ast.ParamStatement, error)

Parse parses the p.src based on the given param types and returns its param statement and an error on failure.

func (*ParamParser) Reset

func (p *ParamParser) Reset(src string)

Reset resets this ParamParser, reset the errors and set the source to the input "src".

Jump to

Keyboard shortcuts

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