tiffany

package module
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: MIT Imports: 6 Imported by: 0

README

tiffany

Build Status Coverage Status GoDoc

Go vanity URL.

Usage

import "subosito.com/go/tiffany"

For example, you can create a server for your vanity import path:

import (
	"net/http"

	"subosito.com/go/tiffany"
)

func Handler(w http.ResponseWriter, r *http.Request) {
    w.Header().Set("Cache-Control", "public, max-age=300")

    tiffany.Render(w, tiffany.Option{
        CanonicalURL: "subosito.com/go/gotenv",
        RepoURL:      "https://github.com/subosito/gotenv",
    })
}

http.Handle("/go/gotenv", Handler)
http.ListenAndServe(":8080", nil)

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w io.Writer, option Option) error

Render renders the vanity URL information based on supplied option.

Example
package main

import (
	"fmt"
	"strings"

	"subosito.com/go/tiffany"
)

func main() {
	out := &strings.Builder{}

	tiffany.Render(out, tiffany.Option{
		CanonicalURL: "subosito.com/go/gotenv",
		RepoURL:      "https://github.com/subosito/gotenv",
	})

	fmt.Println(out.String())
}
Output:

Types

type Option

type Option struct {
	CanonicalURL     string
	RepoURL          string
	VCS              string
	SourceLayout     string
	SourceURL        string
	GodocURL         string
	GodocDisabled    bool
	RedirectURL      string
	RedirectDisabled bool
}

Option is configuration for vanity URL

Jump to

Keyboard shortcuts

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