Skip to content

Commit

Permalink
Fix critical bug in zap.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
issmirnov committed Jun 9, 2017
1 parent f911665 commit 1c3d967
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 1c3d967

Please sign in to comment.