aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrégoire Duchêne <gduchene@awhk.org>2022-01-04 11:23:47 +0000
committerGrégoire Duchêne <gduchene@awhk.org>2022-01-04 11:23:47 +0000
commit77f260ae716bafecca5b19c7a48f6b22b37e5757 (patch)
tree934bc2ad0b8f1b441720951fbd1b7ba90dc96e98
parent22e1387c5b2231c16071e66eea9806228838b0b0 (diff)
Send empty response when redirecting to pkg.go.dev
-rw-r--r--main.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/main.go b/main.go
index 0c361b1..4d8e0b6 100644
--- a/main.go
+++ b/main.go
@@ -29,13 +29,13 @@ func redirect(resp http.ResponseWriter, req *http.Request) {
}
pkg := path.Join(req.Host, req.URL.Path)
- resp.Header().Set("Content-Type", "text/html; charset=utf-8")
- if req.URL.Query().Get("go-get") == "1" {
- resp.WriteHeader(http.StatusOK)
- } else {
+ if req.URL.Query().Get("go-get") != "1" {
resp.Header().Set("Location", "https://pkg.go.dev/"+pkg)
resp.WriteHeader(http.StatusFound)
+ return
}
+ resp.Header().Set("Content-Type", "text/html; charset=utf-8")
+ resp.WriteHeader(http.StatusOK)
if _, err := fmt.Fprint(resp, GetBody(pkg)); err != nil {
log.Println("fmt.Fprint:", err)
}