gopkg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

README

gopkg for Caddy v2

This is a port of the gopkg plugin to Caddy v2.

The plugin allows to easily setup vanity gopkg/go module names through a Caddy-powered website.

Usage

gopkg [path] [repo-uri]

gopkg [path] [vcs] [repo-uri]

zikes.me {
  // default vcs is git
  gopkg /multistatus https://github.com/zikes/multistatus
  gopkg /chrisify https://github.com/zikes/chrisify

  // use mercurial
  gopkg /myrepo hg https://bitbucket.org/zikes/myrepo
}

The above would make the repos go get-able via go get zikes.me/chrisify, go get zikes.me/myrepo, and go get zikes.me/multistatus.

If the urls are visited normally the browser will be redirected to the repo uri.

Once implemented, go get can enforce your import paths with import path checking.

Documentation

Index

Constants

View Source
const DefaultTemplate = `` /* 142-byte string literal not displayed */

DefaultTemplate is the default HTML template used as a response.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	Path string `json:"path"`
	Vcs  string `json:"vcs,omitempty"`
	URI  string `json:"uri"`

	// Template is the template used when returning a response (instead of redirecting).
	Template *template.Template
}

Module represents the GoPkg Caddy module.

func (Module) CaddyModule

func (m Module) CaddyModule() caddy.ModuleInfo

func (*Module) Provision

func (m *Module) Provision(ctx caddy.Context) error

func (Module) ServeHTTP

func (m Module) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (*Module) UnmarshalCaddyfile

func (m *Module) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

UnmarshalCaddyfile implements caddyfile.Unmarshaler. Syntax:

gopkg <path> [<vcs>] <uri>

Jump to

Keyboard shortcuts

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