x: within.website/x/vanity Index | Files

package vanity

import "within.website/x/vanity"

Package vanity implements custom import paths (Go vanity URLs) as an HTTP handler that can be installed at the vanity URL.

Index

Package Files

legal.go vanity.go

func GitHubHandler Uses

func GitHubHandler(importPath, user, repo, gitScheme string) http.Handler

Creates a Handler that serves a GitHub repository at a specific importPath.

func GogsHandler Uses

func GogsHandler(importPath, host, user, repo, gitScheme string) http.Handler

Creates a Handler that serves a repository hosted with Gogs at host at a specific importPath.

func Handler Uses

func Handler(opts ...Option) http.Handler

Handler returns an http.Handler that serves the vanity URL information for a single repository. Each Option gives additional information to agents about the repository or provides help to browsers that may have navigated to the vanity URL. The WithImport Option is mandatory since the go tool requires it to fetch the repository.

func MakeHandler Uses

func MakeHandler(opts ...Option) http.Handler

MakeHandler creates a handler with custom options.

type Option Uses

type Option func(*config)

Configures the Handler. The only required option is WithImport.

func WithGitHubStyleSource Uses

func WithGitHubStyleSource(importPath, repoPath, ref string) Option

Redirects gddo to browsable source files for GitHub hosted repositories.

func WithGoModProxy Uses

func WithGoModProxy(importPath, proxyServer string) Option

WithGoModProxy adds a go module proxy to the option chain.

func WithGogsStyleSource Uses

func WithGogsStyleSource(importPath, repoPath, ref string) Option

Redirects gddo to browsable source files for Gogs hosted repositories.

func WithImport Uses

func WithImport(importPath, vcs, vcsRoot string) Option

Instructs the go tool where to fetch the repo at vcsRoot and the importPath that tree should be rooted at.

func WithRedirector Uses

func WithRedirector(redir Redirector) Option

WithRedirector loads a redirector instance into the config.

func WithSource Uses

func WithSource(prefix, home, directory, file string) Option

Instructs gddo (godoc.org) how to direct browsers to browsable source code for packages and their contents rooted at prefix.

home specifies the home page of prefix, directory gives a format for how to browse a directory, and file gives a format for how to view a file and go to specific lines within it.

More information can be found at https://github.com/golang/gddo/wiki/Source-Code-Links.

type Redirector Uses

type Redirector func(pkg string) (url string)

When a browser navigates to the vanity URL of pkg, this function rewrites pkg to a browsable URL.

Package vanity imports 5 packages (graph) and is imported by 2 packages. Updated 2019-06-07. Refresh now. Tools for package owners.