Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BindParameter ¶
type BindParameter struct { Ident string `parser:"@Ident ':' ' '*"` Value BindParameterValue `parser:"@@"` }
BindParameter is a single pair of bind parameter containing identifier and value that are separated by the colon (":").
type BindParameterValue ¶
type BindParameterValue struct { Literal *string `parser:" @Ident"` Regex *string `parser:"| '/' @Regex '/'"` }
BindParameterValue is a single bind parameter value containing either literal or regex, the latter is surrounded by slashes ("/").
type BindParameters ¶
type BindParameters struct {
Parameters []BindParameter `parser:"( @@ ( ',' ' '* @@ )* )+"`
}
BindParameters is a set of bind parameters that are separated by commas (",").
type Handler ¶
type Handler func(http.ResponseWriter, *http.Request, Params)
Handler is a function that can be registered to a route for handling HTTP requests.
type Leaf ¶
type Leaf interface { // URLPath fills in bind parameters with given values to build the "path" // portion of the URL. If `withOptional` is true, the path will include the // current leaf when it is optional; otherwise, the current leaf is excluded. URLPath(vals map[string]string, withOptional bool) string // Route returns the string representation of the original route. Route() string // Handler the Handler that is associated with the leaf. Handler() Handler // Static returns true if the leaf and all ancestors are static routes. Static() bool // contains filtered or unexported methods }
Leaf is a leaf derived from a segment.
type Params ¶
Params is a set of bind parameters with their values that are extracted from the request path.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is a BNF-based route syntax parser using stateful lexer.
type Route ¶
type Route struct { Segments []*Segment `parser:"@@+"` // contains filtered or unexported fields }
Route is a single route containing segments that are separated by slashes ("/").
type Segment ¶
type Segment struct { Pos lexer.Position Slash string `parser:"'/'"` Optional bool `parser:"@'?'?"` Elements []SegmentElement `parser:"@@*"` // contains filtered or unexported fields }
Segment is a single segment containing multiple elements.
type SegmentElement ¶
type SegmentElement struct { Pos lexer.Position EndPos lexer.Position Ident *string `parser:" @Ident"` BindIdent *string `parser:"| '{' @Ident '}'"` BindParameters *BindParameters `parser:"| '{' @@ '}'"` }
SegmentElement is a single segment element containing either identifier, bind identifier or a list of bind parameters. Bind identifier and the list of bind parameters are surrounded by brackets ("{}").
type Tree ¶
type Tree interface { // Match matches a leaf for the given request path, values of bind parameters // are stored in the `Params`. The `Params` may contain extra values that do not // belong to the final leaf due to backtrace. Match(path string) (Leaf, Params, bool) // contains filtered or unexported methods }
Tree is a tree derived from a segment.