From 7e9549ca07d64fab942f05373521024eb45b2faa Mon Sep 17 00:00:00 2001 From: Shulhan Date: Fri, 10 Nov 2023 01:15:14 +0700 Subject: [DO-NOT-MERGE] cmd/golangorg: allow serving in local as "go.local" Change-Id: I73aa112ba125b56dbdaf2727a3a7165c03de9b3f --- cmd/golangorg/server.go | 4 +++- internal/pkgdoc/doc.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/golangorg/server.go b/cmd/golangorg/server.go index 3b015f98..827dedba 100644 --- a/cmd/golangorg/server.go +++ b/cmd/golangorg/server.go @@ -552,7 +552,9 @@ func hostEnforcerHandler(h http.Handler) http.Handler { // link back to URLs on the test site. func hostPathHandler(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Host != "localhost" && !strings.HasPrefix(r.Host, "localhost:") && !strings.HasSuffix(r.Host, ".appspot.com") { + if r.Host != "localhost" && !strings.HasPrefix(r.Host, "localhost:") && + !strings.HasSuffix(r.Host, ".appspot.com") && + !strings.HasSuffix(r.Host, `.local`) { h.ServeHTTP(w, r) return } diff --git a/internal/pkgdoc/doc.go b/internal/pkgdoc/doc.go index 75e556df..98d48a67 100644 --- a/internal/pkgdoc/doc.go +++ b/internal/pkgdoc/doc.go @@ -437,7 +437,7 @@ func (d *docs) ServeHTTP(w http.ResponseWriter, r *http.Request) { suffix += "GOARCH=" + url.QueryEscape(goarch) } } - http.Redirect(w, r, "https://pkg.go.dev/"+relpath+suffix, http.StatusTemporaryRedirect) + http.Redirect(w, r, "https://pkg.go.local/"+relpath+suffix, http.StatusTemporaryRedirect) return } -- cgit v1.3