vanity

package module
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

README

vanity

Utilities for building vanity Go import servers. See documentation at https://godoc.org/acln.ro/vanity.

TODO(acln): document this better one day, once I'm satisfied with the API

Documentation

Overview

Package vanity provides utilities for building vanity Go import servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGoGet

func IsGoGet(req *http.Request) bool

IsGoGet returns a boolean indicating whether req is a go get HTTP request.

func RedirectToGodoc

func RedirectToGodoc(w http.ResponseWriter, req *http.Request)

RedirectToGodoc redirects req to the corresponding godoc page.

The redirect URL is derived from req.Host and req.URL.Path. For example, a request to example.com/foo/bar is redirected to godoc.org/example.com/foo/bar.

Types

type ImportPath

type ImportPath struct {
	VCS  string
	From string
	To   string
}

ImportPath defines a mapping between Go import paths.

func (ImportPath) TagFor

func (ip ImportPath) TagFor(req *http.Request) (*ImportTag, error)

TagFor returns the import tag for the request req.

TagFor verifies that the import path specified by req is either identical to ip.From or a sub-path of it.

It returns an ImportTag pointing to the root of the import path, ip.From.

For example, given ip.From == "acln.ro/foo" and a request to "acln.ro/foo/bar", the returned ImportTag would have .ImportPath == "acln.ro/foo".

func (ImportPath) WildcardTagFor

func (ip ImportPath) WildcardTagFor(req *http.Request) (*ImportTag, error)

WildcardTagFor returns the wildcard import tag for the request req.

TagFor verifies that the import path specified by req is a strict sub-path of ip.From.

It returns an ImportTag pointing to the root of the import path, based on the first child element of the import path, beyond ip.From.

For example, given ip.From == "acln.ro" and a request to "acln.ro/foo/bar", the returned ImportTag would have .ImportPath == "acln.ro/foo".

type ImportTag

type ImportTag struct {
	ImportPath string
	VCS        string
	VCSRepo    string
}

ImportTag represents an HTML go-import meta tag understood by the go tool.

func (*ImportTag) Render

func (t *ImportTag) Render(w io.Writer) error

Render renders an HTML document to w, containing the go-import meta tag represented by t.

Source Files

Jump to

Keyboard shortcuts

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