bmizerany / pat

MIT License
1.43k stars 115 forks source link

Fix slash match everything #11

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)

bmizerany commented 12 years ago

Oh wow. Thank you. Will merge when I get to a laptop tomorrow.

On Jun 11, 2012, at 8:09 AM, Alexis Svinartchoukreply@reply.github.com wrote:

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) }}

You can merge this Pull Request by running:

git pull https://github.com/zvin/pat fix-slash-match-everything

Or you can view, comment on it, or merge it online at:

https://github.com/bmizerany/pat/pull/11

-- Commit Summary --

  • fix '/' match everything
  • added OPTIONS mehod
  • Merge branch 'master' of git://github.com/binku87/pat into fix-slash-match-everything

-- File Changes --

M mux.go (15) M mux_test.go (8)

-- Patch Links --

https://github.com/bmizerany/pat/pull/11.patch https://github.com/bmizerany/pat/pull/11.diff


Reply to this email directly or view it on GitHub: https://github.com/bmizerany/pat/pull/11

zvin commented 12 years ago

Sorry, this pull request also contains my "add OPTIONS method" patch. If you want, I can recreate a pull request with only the slash fix.

bmizerany commented 12 years ago

Please do.

On Tue, Jun 12, 2012 at 8:58 AM, Alexis Svinartchouk reply@reply.github.com wrote:

Sorry, this pull request also contains my "add OPTIONS method" patch. If you want, I can recreate a pull request with only the slash fix.


Reply to this email directly or view it on GitHub: https://github.com/bmizerany/pat/pull/11#issuecomment-6274478

zvin commented 12 years ago

here it is: https://github.com/bmizerany/pat/pull/12