From f9e599fdbfe895db56a5415d8b053306d09ac471 Mon Sep 17 00:00:00 2001 From: Anirudh Oppiliappan Date: Fri, 19 Sep 2025 14:49:29 +0300 Subject: [PATCH] appview/{pages,middleware}: serve go-import tags for tangled.org as well Signed-off-by: Anirudh Oppiliappan --- appview/middleware/middleware.go | 7 ++++++- appview/pages/templates/repo/fragments/meta.html | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/appview/middleware/middleware.go b/appview/middleware/middleware.go index c15749bf..7c2d7a73 100644 --- a/appview/middleware/middleware.go +++ b/appview/middleware/middleware.go @@ -317,6 +317,10 @@ func (mw Middleware) ResolveIssue() middlewareFunc { // 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) { @@ -332,7 +336,8 @@ func (mw Middleware) GoImport() middlewareFunc { if r.Header.Get("User-Agent") == "Go-http-client/1.1" { if r.URL.Query().Get("go-get") == "1" { html := fmt.Sprintf( - ``, + ` +`, fullName, fullName, ) diff --git a/appview/pages/templates/repo/fragments/meta.html b/appview/pages/templates/repo/fragments/meta.html index 2fb0dd36..a69498c1 100644 --- a/appview/pages/templates/repo/fragments/meta.html +++ b/appview/pages/templates/repo/fragments/meta.html @@ -23,4 +23,8 @@ name="go-import" content="tangled.sh/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.sh/{{ .RepoInfo.FullName }}" /> + {{ end }} -- 2.51.2