handler

package
v0.0.0-...-b258b5d Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrReadConfigFile  = fmt.Errorf("failed to read rules config file")
	ErrParseConfigFile = fmt.Errorf("failed to parse rules config file")
)

custom errors.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Handler struct.

func New

func New(opt ...Option) *Handler

New handler struct.

func (*Handler) GetImportRules

func (h *Handler) GetImportRules() error

GetImportRules loads config file (import path mapping rules)

func (*Handler) ReloadRules

func (h *Handler) ReloadRules(w http.ResponseWriter, r *http.Request)

ReloadRules is the handler that reloads mapping rules from config.

func (*Handler) VanityServer

func (h *Handler) VanityServer(w http.ResponseWriter, r *http.Request)

VanityServer redirects browsers to godoc or go tool to VCS repository.

type Option

type Option func(*Options)

Option type

func WithConfigFile

func WithConfigFile(configFile string) Option

WithConfigFile sets the config file path.

func WithGodocURL

func WithGodocURL(godocURL string) Option

WithGodocURL sets the redirect URL for godoc.

type Options

type Options struct {
	ConfigFile   string
	GodocURL     string
	MappingRules []Rules
}

Options struct

func NewOptions

func NewOptions(options ...Option) Options

NewOptions returns a new set of options for the http handler.

type Rules

type Rules struct {
	ImportRoot string `json:"importroot"`
	VCS        string `json:"vcs"`
	RepoRoot   string `json:"reporoot"`
}

Rules for mapping go-import.

Jump to

Keyboard shortcuts

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