vanity

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: BSD-3-Clause Imports: 3 Imported by: 2

README

kkn.fi/vanity

Build Status GoDoc

Concepts

  • VCS is Version Control System (such as Git or Mercurial)
  • VCS root is the root path the source code repository (such as github.com/kare)
  • Domain is the internet address where the Go Vanity server is hosted (such as 9fans.net or kkn.fi)
  • Path is the path component of the Go package (such as /cmd/tcpproxy in kkn.fi/cmd/tcpproxy)

Features

  • Redirects browsers to pkg.go.dev
  • Redirects Go tool to VCS
  • Redirects HTTP to HTTPS
  • Automatic configuration of packages:
    • All packages are redirected with full path to vcsroot.
    • Packages whose path is prefixed with "/cmd/" redirect automatically to vcsroot by stripping the "/cmd" prefix from the package path. Example: Redirect request "kkn.fi/cmd/tcpproxy" to "github.com/kare/tcpproxy"
  • Configurable logger which is fully compatible with standard log package

Installation

go get kkn.fi/vanity

Specification

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Redirect added in v0.2.0

func Redirect(vcs, importPath, repoRoot string) http.Handler

Redirect is an HTTP middleware that redirects browsers to pkg.go.dev or Go tool to VCS repository.

Example
package main

import (
	"net/http"

	"kkn.fi/vanity"
)

func main() {
	http.Handle("/", vanity.Redirect("git", "kkn.fi", "github.com/kare"))
}
Output:

func SetLogger added in v0.2.0

func SetLogger(l Logger)

SetLogger sets the logger used by vanity package's error log.

Example
package main

import (
	"log"
	"os"

	"kkn.fi/vanity"
)

func main() {
	errorLog := log.New(os.Stderr, "vanity: ", log.Ldate|log.Ltime|log.LUTC)
	vanity.SetLogger(errorLog)
}
Output:

Types

type Logger added in v0.2.0

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger describes functions available for logging purposes.

Directories

Path Synopsis
cmd module
vanity Module

Jump to

Keyboard shortcuts

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