server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cobra.Command{
	Use:     "server [flags] package_mapping ...",
	Short:   "Run the govanity server",
	Example: "  govanity server go.codello.dev/govanity=github.com/codello/govanity",
	Long: `govanity is a simple server for Go vanity URLs.

The configuration is done entirely via the command line by specifying package
mappings. A package mapping looks like this:
  prefix=[vcs:]repo-root
This maps the package prefix to the repo root using the vcs protocol. If vcs is
not present, it defaults to git.

If the prefix starts with a / the prefix will be matched independently of the
hostname of the request. The server will then prepend the hostname of the
request to the package name. Use this if you want to map the prefix to a repo,
regardless of the hostname used to resolve the package.
If the prefix does not start with a / the first path component is assumed to be
the hostname. The prefix will only match if the request hostname matches this
part of the prefix and the part matches the corresponding prefix.
`,
	RunE: runServer,
	Args: cobra.MinimumNArgs(1),
}

Command is the command that runs the govanity server.

Functions

func PackageHandler

func PackageHandler(prefix string, vcs string, repoRoot string) http.Handler

PackageHandler returns a http.Handler that renders the package meta page for the package prefix. The rendered page will indicate that the source for the page can be found at repoRoot using vcs.

func ParsePackageMapping

func ParsePackageMapping(spec string) (prefix, vcs, repoRoot string, err error)

ParsePackageMapping converts a "prefix=[vcs:]repo-root" spec into prefix, vcs and repoRoot. If a parsing error occurs, err will be non-nil.

Types

This section is empty.

Jump to

Keyboard shortcuts

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