Documentation ¶
Index ¶
- Constants
- Variables
- func FixDefUnitVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)
- func FixRepoRevSpecVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)
- func FixTreeEntryVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)
- func MapToArray(m map[string]string) (a []string)
- func NewAPIRouter(base *mux.Router) *mux.Router
- func PrepareDefRouteVars(vars map[string]string) map[string]string
- func PrepareRepoRevSpecRouteVars(vars map[string]string) map[string]string
- func PrepareTreeEntryRouteVars(vars map[string]string) map[string]string
Constants ¶
const ( Build = "build" BuildDequeueNext = "build.dequeue-next" BuildUpdate = "build.update" BuildLog = "build.log" Builds = "builds" BuildTasks = "build.tasks" BuildTaskUpdate = "build.task" BuildTasksCreate = "build.tasks.create" BuildTaskLog = "build.task.log" Org = "org" OrgMembers = "org.members" OrgSettings = "org.settings" OrgSettingsUpdate = "org.settings.update" Users = "users" User = "user" UserOrgs = "user.orgs" UserAuthors = "user.authors" UserClients = "user.clients" UserEmails = "user.emails" UserFromGitHub = "user.from-github" UserRepoContributions = "user.repo-contributions" UserRepoDependencies = "user.repo-dependencies" UserRepoDependents = "user.repo-dependents" UserRefreshProfile = "user.refresh-profile" UserSettings = "user.settings" UserSettingsUpdate = "user.settings.update" UserComputeStats = "user.compute-stats" Person = "person" RepoPullRequests = "repo.pull-requests" RepoPullRequest = "repo.pull-request" RepoPullRequestMerge = "repo.pull-request.merge" RepoPullRequestComments = "repo.pull-request.comments" RepoPullRequestCommentsCreate = "repo.pull-request.comments.create" RepoPullRequestCommentsEdit = "repo.pull-request.comments.edit" RepoPullRequestCommentsDelete = "repo.pull-request.comments.delete" RepoIssues = "repo.issues" RepoIssue = "repo.issue" RepoIssueComments = "repo.issue.comments" RepoIssueCommentsCreate = "repo.issue.comments.create" RepoIssueCommentsEdit = "repo.issue.comments.edit" RepoIssueCommentsDelete = "repo.issue.comments.delete" Repos = "repos" ReposCreate = "repos.create" ReposGetOrCreate = "repos.get-or-create" Repo = "repo" RepoAuthors = "repo.authors" RepoClients = "repo.clients" RepoDependents = "repo.dependents" RepoDependencies = "repo.dependencies" RepoBadge = "repo.badge" RepoBadges = "repo.badges" RepoCounter = "repo.counter" RepoCounters = "repo.counters" RepoReadme = "repo.readme" RepoBuildsCreate = "repo.builds.create" RepoBuildDataEntry = "repo.build-data.entry" RepoTreeEntry = "repo.tree.entry" RepoTreeSearch = "repo.tree.search" RepoRefreshProfile = "repo.refresh-profile" RepoRefreshVCSData = "repo.refresh-vcs-data" RepoComputeStats = "repo.compute-stats" RepoSettings = "repo.settings" RepoSettingsUpdate = "repo.settings.update" RepoStats = "repo.stats" RepoCombinedStatus = "repo.combined-status" RepoStatusCreate = "repo.status.create" RepoBuild = "repo.build" RepoCommits = "repo.commits" RepoCommit = "repo.commit" RepoCompareCommits = "repo.compare-commits" RepoTags = "repo.tags" RepoBranches = "repo.branches" Search = "search" SearchComplete = "search.complete" SearchSuggestions = "search.suggestions" Snippet = "snippet" Defs = "defs" Def = "def" DefRefs = "def.refs" DefExamples = "def.examples" DefAuthors = "def.authors" DefClients = "def.clients" DefDependents = "def.dependents" DefVersions = "def.versions" Delta = "delta" DeltaUnits = "delta.units" DeltaDefs = "delta.defs" DeltaDependencies = "delta.dependencies" DeltaFiles = "delta.files" DeltaAffectedAuthors = "delta.affected-authors" DeltaAffectedClients = "delta.affected-clients" DeltaAffectedDependents = "delta.affected-dependents" DeltaReviewers = "delta.reviewers" DeltasIncoming = "deltas.incoming" Unit = "unit" Units = "units" Markdown = "markdown" ExtGitHubReceiveWebhook = "ext.github.receive-webhook" // Redirects for old routes. RedirectOldRepoBadgesAndCounters = "repo.redirect-old-badges-and-counters" )
Variables ¶
var DefPathPattern = `.{UnitType}/{rawUnit:.*}.def{Path:(?:(?:/(?:[^/.][^/]*/)*(?:[^/.][^/]*))|)}`
DefPathPattern is the path pattern for defs.
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 ExtraConfig func(base, user *mux.Router)
ExtraConfig, if non-nil, is called by NewAPIRouter with the *mux.Router after setting up routes in this package and before returning it. It can be used by external packages that use this API router and want to add additional routes to it.
var PathComponentNoLeadingDot = `(?:[^/]*(?:/` + noDotDotOrSlash + `)*)`
PathComponentNoLeadingDot is a pattern that matches any string that doesn't contain "/.".
var PersonSpecPattern = `{PersonSpec:[^@/]+(?:@[^@/]+)?}`
var RepoRevSpecPattern = RepoSpecPathPattern + `{Rev:(?:@` + PathComponentNoLeadingDot + `)?}`
RepoRevSpecPattern is the path pattern for encoding RepoRevSpec.
var RepoSpecPathPattern = `{RepoSpec:(?:(?:[^/.@][^/@]*/)+(?:[^/.@][^/@]*))|(?:R\$\d+)}`
RepoSpecPattern is the path pattern for encoding RepoSpec.
var TreeEntryPathPattern = `{Path:(?:/.*)*}`
TreeEntryPathPattern is the path pattern for tree entries.
var UserSpecPattern = `{UserSpec:[^@/]+}`
Functions ¶
func FixDefUnitVars ¶
FixDefUnitVars is a mux.PostMatchFunc that cleans up the dummy rawUnit route variable matched by DefPathPattern. See the docs for DefPathPattern for more information.
func FixRepoRevSpecVars ¶
FixRepoRevSpecVars is a mux.PostMatchFunc that cleans and normalizes the RepoRevSpecPattern vars.
func FixTreeEntryVars ¶
FixTreeEntryVars is a mux.PostMatchFunc that cleans and normalizes the path to a tree entry.
func MapToArray ¶
func NewAPIRouter ¶
NewAPIRouter creates a new API router with route URL pattern definitions but no handlers attached to the routes.
It is in a separate package from app so that other packages may use it to generate URLs without resulting in Go import cycles (and so we can release the router as open-source to support our client library).
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 PrepareRepoRevSpecRouteVars ¶
PrepareRepoRevSpecRouteVars is a mux.BuildVarsFunc that converts from a RepoRevSpec's route vars to components used to generate routes.
Types ¶
This section is empty.