From ef669b8df0c3a624a3c47815e288ff6467d9ad92 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sun, 17 Feb 2013 21:40:57 -0800 Subject: [PATCH] website: redirect /issue/NNN to codesite issue tracker Change-Id: I323311421bb9d72eb043f3694d78a9bc9931a3d6 --- website/camweb.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/website/camweb.go b/website/camweb.go index fc67fe74d..1715ebea9 100644 --- a/website/camweb.go +++ b/website/camweb.go @@ -321,6 +321,7 @@ func main() { Static: http.StripPrefix("/code/", http.FileServer(http.Dir(*gitwebFiles))), }}) } + mux.HandleFunc("/issue/", issueRedirect) mux.HandleFunc("/", mainHandler) if *buildbotHost != "" && *buildbotBackend != "" { @@ -363,6 +364,17 @@ func main() { log.Fatalf("Serve error: %v", <-errch) } +var issueNum = regexp.MustCompile(`^/issue/(\d+)$`) + +func issueRedirect(w http.ResponseWriter, r *http.Request) { + m := issueNum.FindStringSubmatch(r.URL.Path) + if m == nil { + http.Error(w, "Bad request", 400) + return + } + http.Redirect(w, r, "https://code.google.com/p/camlistore/issues/detail?id=" + m[1], http.StatusFound) +} + type fixUpGitwebUrls struct { handler http.Handler }