bmizerany / pat

MIT License
1.43k stars 115 forks source link

Fix slash match everything2 #12

Closed zvin closed 12 years ago

zvin commented 12 years ago

We should merge this binku87 commit, it fixes a panic with m.Get("/", http.HandlerFunc(...)) handlers :

2012/06/11 16:48:22 http: panic serving 127.0.0.1:36657: runtime error: index out of range /usr/lib/go/src/pkg/net/http/server.go:576 (0x447bba) _func_003: buf.Write(debug.Stack()) /build/buildd/golang-stable-1/src/pkg/runtime/proc.c:1443 (0x40fb00) /build/buildd/golang-stable-1/src/pkg/runtime/runtime.c:128 (0x4105cc) /build/buildd/golang-stable-1/src/pkg/runtime/runtime.c:85 (0x410473) /home/alexis/go/src/github.com/zvin/pat/mux.go:217 (0x42756d) com/zvin/pat.(_patHandler).try: if ph.pat[len(ph.pat)-1] == '/' { /home/alexis/go/src/github.com/zvin/pat/mux.go:118 (0x426cc3) com/zvin/pat.(PatternServeMux).ServeHTTP: if , ok := ph.try(r.URL.Path); ok { /usr/lib/go/src/pkg/net/http/server.go:924 (0x43ca95) (_ServeMux).ServeHTTP: mux.handler(r).ServeHTTP(w, r) /usr/lib/go/src/pkg/net/http/server.go:656 (0x43ba26) (_conn).serve: handler.ServeHTTP(w, w.req) /build/buildd/golang-stable-1/src/pkg/runtime/proc.c:271 (0x40dc06)