julienschmidt/httprouter — pull request #47 by jamescun (2014-12-12 21:55:52+00:00)
Title: Use net/http Request.Form for params instead of Params

The motivation behind this PR is to attempt to use the existing `Form` map in the http.Request struct instead of adding an additional parameter, `Params`, to the Handler function. This has the advantage of being compatible with handlers following the syntax of the `net/http` package while maintaining the ability to use URL parameters.

Using GitHub as the example from `go-http-routing-benchmark`; JHttpRouter can be seen to be slower and using a little more memory, there are fewer memory allocations. I feel the downsides may be an acceptable trade off for compatibility.

BenchmarkJHttpRouter_GithubStatic 20000000 86.6 ns/op 0 B/op 0 allocs/op
BenchmarkHttpRouter_GithubStatic 20000000 77.4 ns/op 0 B/op 0 allocs/op
BenchmarkJHttpRouter_GithubParam 3000000 472 ns/op 180 B/op 0 allocs/op
BenchmarkHttpRouter_GithubParam 5000000 340 ns/op	96 B/op 1 allocs/op
BenchmarkJHttpRouter_GithubAll 20000 82118 ns/op 19235 B/op 0 allocs/op
BenchmarkHttpRouter_GithubAll 30000 60360 ns/op 13792 B/op 167 allocs/op

While I believe this may be at odds with @julienschmidt 's ideology for httprouter, I am still interested in their feedback and thoughts :)