diff options
| author | Christine Dodrill <me@christine.website> | 2019-06-06 18:11:17 -0400 |
|---|---|---|
| committer | Christine Dodrill <me@christine.website> | 2019-06-06 18:18:13 -0400 |
| commit | 3db4a0e4efdefcf784726dc61fe0c1292f0cce22 (patch) | |
| tree | 6fc3b24876ebbe312d24333300eeed44039ba561 | |
| parent | f8202976dd7c1c1445957387962f21c2c3480fec (diff) | |
| download | x-3db4a0e4efdefcf784726dc61fe0c1292f0cce22.tar.xz x-3db4a0e4efdefcf784726dc61fe0c1292f0cce22.zip | |
vanity: support go modules
| -rw-r--r-- | vanity/vanity.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/vanity/vanity.go b/vanity/vanity.go index 8be2a80..933d7ed 100644 --- a/vanity/vanity.go +++ b/vanity/vanity.go @@ -30,6 +30,11 @@ func WithImport(importPath, vcs, vcsRoot string) Option { } } +// WithGoModProxy adds a go module proxy to the option chain. +func WithGoModProxy(importPath, proxyServer string) Option { + return WithImport(importPath, "mod", proxyServer) +} + // Instructs gddo (godoc.org) how to direct browsers to browsable source code // for packages and their contents rooted at prefix. // @@ -164,20 +169,22 @@ func WithGogsStyleSource(importPath, repoPath, ref string) Option { } // Creates a Handler that serves a GitHub repository at a specific importPath. -func GitHubHandler(importPath, user, repo, gitScheme string) http.Handler { +func GitHubHandler(importPath, user, repo, gitScheme, proxyServer string) http.Handler { ghImportPath := "github.com/" + user + "/" + repo return Handler( WithImport(importPath, "git", gitScheme+"://"+ghImportPath), + WithGoModProxy(importPath, proxyServer), WithGitHubStyleSource(importPath, "https://"+ghImportPath, "master"), ) } // Creates a Handler that serves a repository hosted with Gogs at host at a // specific importPath. -func GogsHandler(importPath, host, user, repo, gitScheme string) http.Handler { +func GogsHandler(importPath, host, user, repo, gitScheme, proxyServer string) http.Handler { gogsImportPath := host + "/" + user + "/" + repo return Handler( WithImport(importPath, "git", gitScheme+"://"+gogsImportPath), + WithGoModProxy(importPath, proxyServer), WithGogsStyleSource(importPath, "https://"+gogsImportPath, "master"), ) } |
