all repos — homestead @ b8a2bb93e2b2cc9cc609053d02b9cdd7d64de0c3

Code for my website

add special case for handling go-get queries

Alan Pearce
commit

b8a2bb93e2b2cc9cc609053d02b9cdd7d64de0c3

parent

62c36b5b667ab10936f444e01e6f2c567c7c2126

1 file changed, 5 insertions(+), 1 deletion(-)

changed files
M internal/website/mux.gointernal/website/mux.go
@@ -46,7 +46,11 @@ }
} func (website *Website) ServeHTTP(w http.ResponseWriter, r *http.Request) *ihttp.Error { - urlPath, shouldRedirect := website.reader.CanonicalisePath(r.URL.Path) + urlPath := r.URL.Path + if r.URL.Query().Has("go-get") && r.URL.Query().Get("go-get") == "1" { + urlPath = "/go" + r.URL.Path + } + urlPath, shouldRedirect := website.reader.CanonicalisePath(urlPath) if shouldRedirect { website.counter.Count(r, "302") http.Redirect(w, r, urlPath, http.StatusFound)