Documentation
¶
Overview ¶
Package routevar contains mux route variable declarations (e.g., `{Repo:<regexp>}`) and PostMatchFuncs/BuildVarsFuncs.
Index ¶
- Variables
- func FixDefUnitVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)
- func FixRepoRevVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)
- func FixResolvedRevVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)
- func FixTreeEntryVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)
- func NamedToNonCapturingGroups(pat string) string
- func PrepareDefRouteVars(vars map[string]string) map[string]string
- func PrepareRepoRevRouteVars(vars map[string]string) map[string]string
- func PrepareResolvedRevRouteVars(vars map[string]string) map[string]string
- func PrepareTreeEntryRouteVars(vars map[string]string) map[string]string
Constants ¶
This section is empty.
Variables ¶
var ( // Repo captures RepoSpec strings in URL routes. Repo = `{Repo:` + NamedToNonCapturingGroups(spec.RepoPattern) + `}` // RepoRev captures RepoRevSpec strings in URL routes. RepoRev = Repo + `{ResolvedRev:(?:@` + NamedToNonCapturingGroups(spec.ResolvedRevPattern) + `)?}` )
var ( // User captures UserSpec strings in URL routes. User = `{User:` + NamedToNonCapturingGroups(spec.UserPattern) + `}` // Person captures PersonSpec strings in URL routes. Person = `{Person:` + NamedToNonCapturingGroups(spec.UserPattern) + `}` )
var Def = `.{UnitType}/{rawUnit:.*}.def{Path:(?:(?:/(?:[^/.][^/]*/)*(?:[^/.][^/]*))|)}`
Def captures def paths in URL routes.
We want the def routes to match the 2 following forms:
- /.MyUnitType/.def/MyDef (i.e., Unit == ".")
- /.MyUnitType/MyUnitPath1/.def/MyDef (i.e., Unit == "MyUnitPath1")
To achieve this, we use a non-picky regexp for rawUnit and then sort it out in the FixDefUnitVars PostMatchFunc.
var TreeEntryPath = `{Path:(?:/.*)*}`
TreeEntryPath captures tree entry paths in URL routes.
Functions ¶
func FixDefUnitVars ¶
FixDefUnitVars is a mux.PostMatchFunc that cleans up the dummy rawUnit route variable matched by Def. See the docs for Def for more information.
func FixRepoRevVars ¶
FixRepoRevVars is a mux.PostMatchFunc that cleans and normalizes the route vars pertaining to a RepoRev.
func FixResolvedRevVars ¶
FixResolvedRevVars is a mux.PostMatchFunc that cleans and normalizes the route vars pertaining to a ResolvedRev (Rev and CommitID).
func FixTreeEntryVars ¶
FixTreeEntryVars is a mux.PostMatchFunc that cleans and normalizes the path to a tree entry.
func NamedToNonCapturingGroups ¶
NamedToNonCapturingGroups converts named capturing groups `(?P<myname>...)` to non-capturing groups `(?:...)` for use in mux route declarations (which assume that the route patterns do not have any capturing groups).
func PrepareDefRouteVars ¶
PrepareDefRouteVars is a mux.BuildVarsFunc that converts from a "Unit" route variable to the dummy "rawUnit" route variable that actually appears in the route regexp pattern.
func PrepareRepoRevRouteVars ¶
PrepareRepoRevRouteVars is a mux.BuildVarsFunc that converts from a RepoRevSpec's route vars to components used to generate routes.
func PrepareResolvedRevRouteVars ¶
PrepareResolvedRevRouteVars is a mux.BuildVarsFunc that converts from a ResolvedRev's component route vars (Rev and CommitID) to a single ResolvedRev var.
Types ¶
This section is empty.