A production server is seeing a significant amount of allocations in (*routeRegexp).getURLQuery
Since it is only interested in a single value and only the first value we create a specialized function for that.
Comparing a few parameter parsing scenarios:
```
Benchmark_findQueryKey/0-8 7184014 168 ns/op 0 B/op 0 allocs/op
Benchmark_findQueryKey/1-8 5307873 227 ns/op 48 B/op 3 allocs/op
Benchmark_findQueryKey/2-8 1560836 770 ns/op 483 B/op 10 allocs/op
Benchmark_findQueryKey/3-8 1296200 931 ns/op 559 B/op 11 allocs/op
Benchmark_findQueryKey/4-8 666502 1769 ns/op 3 B/op 1 allocs/op
Benchmark_findQueryKeyGoLib/0-8 1740973 690 ns/op 864 B/op 8 allocs/op
Benchmark_findQueryKeyGoLib/1-8 3029618 393 ns/op 432 B/op 4 allocs/op
Benchmark_findQueryKeyGoLib/2-8 461427 2511 ns/op 1542 B/op 24 allocs/op
Benchmark_findQueryKeyGoLib/3-8 324252 3804 ns/op 1984 B/op 28 allocs/op
Benchmark_findQueryKeyGoLib/4-8 69348 14928 ns/op 12716 B/op 130 allocs/op
```
In lieu of checking the template pattern on every Match request, a bool is added to the routeRegexp, and set
if the routeRegexp is a host AND there is no ":" in the template. I dislike extending the type, but I'd dislike
doing a string match on every single Match, even more.
Previously, getHost only returned the host. As it now returns the
port as well, any .Host matches on a route will need to be updated
to also support matching on the port for cases where the port is
non default, eg: 80 for http or 443 for https.
* Pull out common shared `routeConf` so that config is pushed on to child
routers and routes.
* Removes obsolete usages of `parentRoute`
* Add tests defining compositional behavior
* Exercise `copyRouteConf` for posterity
The existing options matchPrefix, matchHost, and matchQueries are
mutually exclusive so there's no point in having a separate boolean
argument for each one. It's clearer if there's a single type variable.
strictSlash and useEncodedPath were also being passed as naked bools so
I've wrapped these in a struct called routeRegexpOptions for more clarity
at the call site.
* Add mechanism to route based on the escaped path, correct request mocking in tests
* Remove unneccessary regex matching, substitute with string slicing
* Add test case and handling for requests with no host/scheme
The router now associates a regexp named group with each mux variable.
It only fills variables when capturing group name match instead of
relying on indices, which doesn't work if a variable regexp has interior
capturing groups.
Fixes#62