forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

appview/{pages,middleware}: serve go-import tags for tangled.org as well

Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.sh>

anirudh.fi f9e599fd 11737c53

verified
Changed files
+10 -1
appview
middleware
pages
templates
repo
fragments
+6 -1
appview/middleware/middleware.go
···
// this should serve the go-import meta tag even if the path is technically
// a 404 like tangled.sh/oppi.li/go-git/v5
+
//
+
// we're keeping the tangled.sh go-import tag too to maintain backward
+
// compatiblity for modules that still point there. they will be redirected
+
// to fetch source from tangled.org
func (mw Middleware) GoImport() middlewareFunc {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
···
if r.Header.Get("User-Agent") == "Go-http-client/1.1" {
if r.URL.Query().Get("go-get") == "1" {
html := fmt.Sprintf(
-
`<meta name="go-import" content="tangled.sh/%s git https://tangled.sh/%s"/>`,
+
`<meta name="go-import" content="tangled.sh/%s git https://tangled.sh/%s"/>
+
<meta name="go-import" content="tangled.org/%s git https://tangled.org/%s"/>`,
fullName,
fullName,
)
+4
appview/pages/templates/repo/fragments/meta.html
···
name="go-import"
content="tangled.sh/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.sh/{{ .RepoInfo.FullName }}"
/>
+
<meta
+
name="go-import"
+
content="tangled.org/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.org/{{ .RepoInfo.FullName }}"
+
/>
{{ end }}