router

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 6, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
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

View Source
var DefPathPattern = `.{UnitType}/{rawUnit:.*}.def{Path:(?:(?:/(?:[^/.][^/]*/)*(?:[^/.][^/]*))|)}`

DefPathPattern is the path pattern for defs.

We want the def routes to match the 2 following forms:

  1. /.MyUnitType/.def/MyDef (i.e., Unit == ".")
  2. /.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.

View Source
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.

View Source
var PathComponentNoLeadingDot = `(?:[^/]*(?:/` + noDotDotOrSlash + `)*)`

PathComponentNoLeadingDot is a pattern that matches any string that doesn't contain "/.".

View Source
var PersonSpecPattern = `{PersonSpec:[^@/]+(?:@[^@/]+)?}`
View Source
var RepoRevSpecPattern = RepoSpecPathPattern + `{Rev:(?:@` + PathComponentNoLeadingDot + `)?}`

RepoRevSpecPattern is the path pattern for encoding RepoRevSpec.

View Source
var RepoSpecPathPattern = `{RepoSpec:(?:(?:[^/.@][^/@]*/)+(?:[^/.@][^/@]*))|(?:R\$\d+)}`

RepoSpecPattern is the path pattern for encoding RepoSpec.

View Source
var TreeEntryPathPattern = `{Path:(?:/.*)*}`

TreeEntryPathPattern is the path pattern for tree entries.

View Source
var UserSpecPattern = `{UserSpec:[^@/]+}`

Functions

func FixDefUnitVars

func FixDefUnitVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)

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

func FixRepoRevSpecVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)

FixRepoRevSpecVars is a mux.PostMatchFunc that cleans and normalizes the RepoRevSpecPattern vars.

func FixTreeEntryVars

func FixTreeEntryVars(req *http.Request, match *mux.RouteMatch, r *mux.Route)

FixTreeEntryVars is a mux.PostMatchFunc that cleans and normalizes the path to a tree entry.

func MapToArray

func MapToArray(m map[string]string) (a []string)

func NewAPIRouter

func NewAPIRouter(base *mux.Router) *mux.Router

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

func PrepareDefRouteVars(vars map[string]string) map[string]string

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

func PrepareRepoRevSpecRouteVars(vars map[string]string) map[string]string

PrepareRepoRevSpecRouteVars is a mux.BuildVarsFunc that converts from a RepoRevSpec's route vars to components used to generate routes.

func PrepareTreeEntryRouteVars

func PrepareTreeEntryRouteVars(vars map[string]string) map[string]string

PrepareTreeEntryRouteVars is a mux.BuildVarsFunc that converts from a cleaned and normalized Path to a Path that we use to generate tree entry URLs.

Types

This section is empty.

Jump to

Keyboard shortcuts

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