From 77f260ae716bafecca5b19c7a48f6b22b37e5757 Mon Sep 17 00:00:00 2001 From: GrĂ©goire DuchĂȘne Date: Tue, 4 Jan 2022 11:23:47 +0000 Subject: Send empty response when redirecting to pkg.go.dev --- main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'main.go') 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) } -- cgit v1.2.3-70-g09d2