From 1c3d967fd62d41ac82c15608e3122fb256fe66dd Mon Sep 17 00:00:00 2001 From: Ivan Smirnov Date: Fri, 9 Jun 2017 00:22:02 -0700 Subject: [PATCH] Fix critical bug in zap. As it turns out, there were some changes in the julienschmidt/httprouter project that break certain assumptions made about wildcard handling. Most likely, this is related to commit 6f3f391, and manifested in issues 183 and 172. Zap unit tests did not catch this since we use a HTTP recorder rather than the actual framework. For now, adding a small hack that registers the index handler as the notfound handler. --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 17baf5a..19dfab6 100644 --- a/main.go +++ b/main.go @@ -62,6 +62,11 @@ func main() { router.Handler("GET", "/varz", ctxWrapper{context, VarsHandler}) router.HandlerFunc("GET", "/healthz", HealthHandler) + // https://github.com/julienschmidt/httprouter is having issues with + // wildcard handling. As a result, we have to register index handler + // as the fallback. Fix incoming. + router.NotFound = ctxWrapper{context, IndexHandler} + // TODO check for errors - addr in use, sudo issues, etc. fmt.Printf("Launching %s on %s:%d\n", appName, *host, *port) log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%d", *host, *port), router))